function getOneColumnAsArray()
 {
     $column = array();
     $queryId = $this->connection->execute($this->getSQL());
     while (is_array($row = Mysqli_fetch_row($queryId))) {
         $column[] = $row[0];
     }
     Mysqli_free_result($queryId);
     return $column;
 }
Exemplo n.º 2
0
 function loadTables()
 {
     if ($this->isExisting) {
         $queryId = $this->connection->execute("SHOW TABLES FROM `" . $this->name . "`");
         while (is_array($row = Mysqli_fetch_row($queryId))) {
             $this->tables[$row[0]] = null;
         }
         Mysqli_free_result($queryId);
         $this->isTablesLoaded = true;
     } else {
         $this->tables = array();
     }
 }
Exemplo n.º 3
0
 function count()
 {
     if (!(preg_match("/^\\s*SELECT\\s+DISTINCT/is", $this->query) || preg_match('/\\s+GROUP\\s+BY\\s+/is', $this->query)) && preg_match("/^\\s*SELECT\\s+.+\\s+FROM\\s+/Uis", $this->query)) {
         //optimization for non paginated queries
         if (!$this->limit && $this->queryId && $this->valid()) {
             return mysqli_num_rows($this->queryId);
         }
         $rewritesql = preg_replace('/^\\s*SELECT\\s.*\\s+FROM\\s/Uis', 'SELECT COUNT(*) FROM ', $this->query);
         $rewritesql = preg_replace('/(\\sORDER\\s+BY\\s.*)/is', '', $rewritesql);
         $queryId = $this->connection->execute($rewritesql);
         $row = Mysqli_fetch_row($queryId);
         Mysqli_free_result($queryId);
         if (is_array($row)) {
             return $row[0];
         }
     }
     // could not re-write the query, try a different method.
     $queryId = $this->connection->execute($this->query);
     $count = Mysqli_num_rows($queryId);
     Mysqli_free_result($queryId);
     return $count;
 }