Example #1
0
 /**
  * Process indexes
  *
  * @param    string $table
  *
  * @return    string
  */
 protected function _processIndexes($table)
 {
     $sqls = [];
     for ($i = 0, $c = count($this->keys); $i < $c; $i++) {
         if (is_array($this->keys[$i])) {
             for ($i2 = 0, $c2 = count($this->keys[$i]); $i2 < $c2; $i2++) {
                 if (!isset($this->fields[$this->keys[$i][$i2]])) {
                     unset($this->keys[$i][$i2]);
                     continue;
                 }
             }
         } elseif (!isset($this->fields[$this->keys[$i]])) {
             unset($this->keys[$i]);
             continue;
         }
         is_array($this->keys[$i]) or $this->keys[$i] = [$this->keys[$i]];
         $sqls[] = 'CREATE INDEX ' . $this->db->escapeIdentifiers($table . '_' . implode('_', $this->keys[$i])) . ' ON ' . $this->db->escapeIdentifiers($table) . ' (' . implode(', ', $this->db->escapeIdentifiers($this->keys[$i])) . ');';
     }
     return $sqls;
 }
Example #2
0
 /**
  * "Count All" query
  *
  * Generates a platform-specific query string that counts all records in
  * the specified database
  *
  * @param    bool $test Are we running automated tests?
  *
  * @return    int
  */
 public function countAll($test = false)
 {
     $table = $this->QBFrom[0];
     $sql = $this->countString . $this->db->escapeIdentifiers('numrows') . ' FROM ' . $this->db->protectIdentifiers($table, true, null, false);
     if ($test) {
         return $sql;
     }
     $query = $this->db->query($sql);
     if (count($query->getResult()) === 0) {
         return 0;
     }
     $query = $query->getRow();
     $this->resetSelect();
     return (int) $query->numrows;
 }