Beispiel #1
0
 protected function onPrepare($argv = null)
 {
     $this->adapter = Db::getAdapter($this->source);
     $this->prefix = trim($this->adapter->getConfiguration()['prefix'], ' -_.');
     $this->tables = $this->adapter->getForge()->getDbTables();
     if (!empty($this->namespace)) {
         $this->namespace = str_replace('/', '\\', trim($this->namespace, KE_PATH_NOISE));
     }
 }
Beispiel #2
0
 public function buildModel(string $table, string $class, string $path)
 {
     list($namespace, $pureClass) = parse_class($class);
     $dir = dirname($path);
     $tpl = $this->getTplContent();
     $forge = $this->adapter->getForge();
     $vars = $forge->buildTableProps($table);
     $vars['namespace'] = $namespace;
     $vars['class'] = $pureClass;
     $vars['tableName'] = $table;
     $vars['datetime'] = date('Y-m-d H:i:s');
     if (is_file($path)) {
         return ['Fail', PHP_EOL, "File {$path} is existing!"];
     }
     if (!is_dir($dir)) {
         mkdir($dir, 0755, true);
     }
     if (file_put_contents($path, substitute($tpl, $vars))) {
         return ['Success'];
     } else {
         return ['Fail', PHP_EOL, 'I/O error, please try again!'];
     }
 }
Beispiel #3
0
 public function quote(string $value) : string
 {
     return $this->adapter->quote($value);
 }
Beispiel #4
0
 public function getTableColumns(string $table)
 {
     return (new Query())->load($this->queryColumns)->in(['TABLE_NAME' => $table, 'TABLE_SCHEMA' => $this->adapter->getDatabase()])->find();
 }