Since: 2010-09-07
Author: Giovanni Ramos (giovannilauro@gmail.com)
示例#1
0
 /**
  * Displays the total number of records
  * 
  * */
 public function getTotalOfRecords()
 {
     // Returns the total number of records in paging
     if (Pagination::getPaging() == TRUE) {
         return Pagination::getTotalOfRecords();
     } else {
         return count(self::$hasRecords);
     }
 }
示例#2
0
 /**
  * Method to query records in the database
  * 
  * @access private static
  * @param string $query SQL query
  * @param string $type Return type of the query
  * @param string $use Pseudonym of a connection instance
  * @param boolean $count OPTIONAL Counts the number of rows affected
  * @return mixed
  * @throws \PDOException
  */
 private static function selectRecords($query, $type, $use, $count = true)
 {
     try {
         if (is_null($query)) {
             throw new \PDOException(self::$exception['no-argument-sql']);
         }
         if (!is_null($use)) {
             self::setInstance($use);
         }
         $result = null;
         $pdo = self::$instance;
         if (!$pdo instanceof \PDO) {
             throw new \PDOException(self::$exception['no-instance']);
         } else {
             if (Pagination::getPaging() == true) {
                 $pre = $pdo->prepare($query);
                 $pre->execute();
                 $result = $pre->fetchAll(\PDO::FETCH_ASSOC);
                 $query = Pagination::buildQuery($query, $result);
             }
             $pre = $pdo->prepare($query);
             if (!is_object($pre)) {
                 return;
             } else {
                 $pre->execute();
             }
             switch ($type) {
                 case 'num':
                     $result = $pre->fetchAll(\PDO::FETCH_NUM);
                     break;
                 case 'obj':
                     $result = $pre->fetchAll(\PDO::FETCH_OBJ);
                     break;
                 case 'all':
                     $result = $pre->fetchAll(\PDO::FETCH_BOTH);
                     break;
                 default:
                     $result = $pre->fetchAll(\PDO::FETCH_ASSOC);
             }
             if ($count) {
                 self::$rowCount = count($result);
             }
         }
     } catch (\PDOException $e) {
         self::stackTrace($e);
     }
     $pdo = null;
     return $result;
 }
示例#3
0
: <input type="text" name="firstname" /></div>
        <div><?php 
echo $demo::LAST_NAME;
?>
: <input type="text" name="lastname" /></div>
        <div><?php 
echo $demo::MAIL;
?>
: <input type="text" name="mail" /></div>
        <div><input type="submit" value="Register" /></div>
    </form>

    <?php 
echo $demo->getMessage();
?>

    <?php 
echo $demo::TOTAL_USERS;
?>
: <?php 
echo $demo->getTotalOfRecords();
?>

    <?php 
echo $demo->showRecords();
?>

    <?php 
echo pager::getPagination();
?>
</div>