/** * 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); } }
/** * 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; }