예제 #1
0
 public static function __callStatic($method, $args)
 {
     $db = Inflector::uncamelize($method);
     if (fnmatch('*_*', $db)) {
         list($database, $table) = explode('_', $db, 2);
     } else {
         $database = SITE_NAME;
         $table = $db;
     }
     if (empty($args)) {
         return Db::instance($database, $table);
     } elseif (count($args) == 1) {
         $id = Arrays::first($args);
         if (is_numeric($id)) {
             return Db::instance($database, $table)->find($id);
         }
     }
 }
예제 #2
0
파일: Db.php 프로젝트: schpill/standalone
 public function fieldsRow()
 {
     $first = Db::instance($this->db, $this->table)->first(true);
     if ($first) {
         $fields = array_keys($first->assoc());
         unset($fields['id']);
         unset($fields['created_at']);
         unset($fields['updated_at']);
         unset($fields['deleted_at']);
         return $fields;
     } else {
         return [];
     }
 }
예제 #3
0
파일: Log.php 프로젝트: schpill/standalone
 public function __construct($ns)
 {
     $this->ns = $ns;
     $this->db = Db::instance('core', 'log');
 }
예제 #4
0
 public function pivot($model)
 {
     if ($model instanceof Db) {
         $model = $model->model();
     }
     $mTable = $model->db()->table;
     $names = [$this->_db->table, $mTable];
     asort($names);
     $pivot = Inflector::lower('pivot' . implode('', $names));
     return Db::instance($this->_db->db, $pivot);
 }