/**
  * Returns SQL query for SELECT.
  * 
  * @version 0.1.5
  * @param bool $count Shows if the SQL should be generated for COUNT() variant.
  * @return string SQL query part.
  */
 protected function getSQL($count = false)
 {
     // fields list
     if ($count) {
         $fields = 'COUNT(' . $this->db->tableName($this->table) . '.' . $this->db->fieldName('id') . ')';
     } else {
         $fields = $this->db->tableName($this->table) . '.' . $this->db->fieldName('id') . ' AS ' . $this->db->fieldName('id');
     }
     return $this->prepareSQL(array($fields), $count);
 }
Esempio n. 2
0
 /**
  * Returns OTServ database information.
  * 
  * <p>
  * Especialy currently only schema version is available (via <i>'version'</i> key).
  * </p>
  * 
  * @version 0.1.6
  * @since 0.1.6
  * @return array List of schema settings.
  * @throws PDOException On PDO operation error.
  * @example examples/schema.php schema.php
  */
 public function getSchemaInfo()
 {
     $info = array();
     // generates associative array
     /// FIXME: 0.2.0 - Use PDO::FETCH_KEY_ASSOC
     foreach ($this->db->query('SELECT ' . $this->db->fieldName('name') . ', ' . $this->db->fieldName('value') . ' FROM ' . $this->db->tableName('schema_info')) as $row) {
         $info[$row['name']] = $row['version'];
     }
     return $info;
 }