示例#1
0
 /**
  * _getTables
  * @return array
  */
 protected function _getTables()
 {
     $this->tables = array();
     $tables = Set::extract('/TABLE_NAMES/.', $this->_db->query('SHOW TABLES'));
     foreach ($tables as $table) {
         $this->tables = array_merge($this->tables, array_values($table));
     }
     return $this->tables;
 }
示例#2
0
 /**
  * Loads the options from the DB
  */
 public function _loadOptions()
 {
     $this->_realmOptions = array();
     $rows = Datasource::query("select * from " . $this->_optionRealm . "_options where id=" . $this->_internalID);
     // First build up from defaults
     foreach (array_keys($this->_realmConfig) as $optionKey) {
         $this->_realmOptions[$optionKey] = $this->_realmConfig[$optionKey]["default"];
     }
     foreach ($rows as $row) {
         $this->_realmOptions[$row["optionname"]] = $this->_getOptionValue($row["optionvalue"], $this->realmConfig[$row["optionname"]]["type"]);
     }
 }
示例#3
0
 private function cacheTable($tbName)
 {
     ob_start();
     echo "<?class ModelCache_" . $tbName . " extends ModelCache {\n";
     echo "public function ModelCache_{$tbName}() {\n";
     echo "\t\$this->modelSource = '{$tbName}';\n";
     $rs = Datasource::query("describe " . Datasource::escape($tbName));
     foreach ($rs as $row) {
         echo "\$this->modelStructure['" . $row["Field"] . "'] = array();\n";
         echo "\$this->modelStructure['" . $row["Field"] . "']['is_id'] = " . ($row["Key"] == 'PRI' ? "true" : "false") . ";\n";
         echo "\$this->modelStructure['" . $row["Field"] . "']['type'] = '" . $this->parseType($row["Type"]) . "';\n";
         echo "\$this->modelStructure['" . $row["Field"] . "']['null'] = " . ($row["Null"] == 'NO' ? "false" : "true") . ";\n";
         echo "\$this->modelStructure['" . $row["Field"] . "']['maxlength'] = " . $this->parseLength($row["Type"]) . ";\n";
         echo "\$this->modelStructure['" . $row["Field"] . "']['default'] = " . $this->getDefault($row) . ";\n";
     }
     echo "}\n";
     echo "\n}?>\n";
     $cacheContents = ob_get_contents();
     ob_end_clean();
     $cachePointer = fopen(WEBAPP_ROOT . "/tmp/modelcache/" . md5($tbName) . ".php", "w");
     fwrite($cachePointer, $cacheContents);
     flush($cachePointer);
     fclose($cachePointer);
 }