Ejemplo n.º 1
0
 /**
  * Gets a select result from cache if is cached, from db if it's not
  * @return array or false
  */
 private function selectCached($cacheable = true)
 {
     if ($this->builders->limit != "") {
         $this->query .= " LIMIT " . $this->builders->limit;
     }
     //        echo $this->query;
     $db = Config::getDb();
     if (!$cacheable) {
         $cache = false;
     } else {
         $cache = $this->isQueryCached();
     }
     if ($cache !== false) {
         if ($cache != "cached") {
             $this->addToHistory(true, is_array($cache) ? $cache : false, "Errors");
             return $cache;
         }
     }
     //echo $this->query;
     //print_r($arr);
     $arr = $db->QueryArray($this->query, MYSQLI_ASSOC);
     //        print_r($arr);
     if ($db->Error()) {
         $this->addToHistory(false, false, $db->Error());
         return false;
     }
     if (count($arr) == 1 && count($arr[0]) == 1) {
         $arr = $arr[0][0];
     }
     if (strtolower($this->builders->from) != "cache as a") {
         ////echo "aaaaaaa";
         $this->addToHistory(false, $arr, "");
         if ($cacheable) {
             $this->cacheQuery($arr);
         }
     }
     if ($cache == "cached") {
         $db->Query("UPDATE cache SET result='" . serialize($arr) . "',timestamp='" . date('Y-m-d H:i:s') . "' WHERE key_sql='" . md5($this->query) . "'");
     }
     return $arr;
 }
Ejemplo n.º 2
0
 /**
  * 
  * @param type $var
  * @return type
  */
 private function getDbVarInfoByDB($var)
 {
     return array("type" => Config::getDB()->getColumnType($var, $this->name), "default" => Config::getDb()->GetDefaultValue($var, $this->name), "key" => isset($this->keys[$var]) ? $this->keys[$var] : null, "extra" => Config::getDb()->GetColumnExtras($var, $this->name), "nullable" => Config::getDb()->IsNullableColumn($var, $this->name));
 }
Ejemplo n.º 3
0
Archivo: Table.php Proyecto: Zanej/cms
 /**
  * Returns all keys of this table
  */
 private function getAllKeys()
 {
     return Config::getDb()->getAllKeys($this->name);
 }