Exemple #1
0
 public function countRows()
 {
     $cloned = clone $this;
     $cloned instanceof Query;
     $cloned->select = 'COUNT(*)';
     $cloned->offset = null;
     $cloned->group = null;
     return Db::query($cloned->select())->fetchColumn();
 }
Exemple #2
0
 public static function execute($migrationsInstance)
 {
     $executed = Db::query('SELECT alias FROM db_migrations')->fetchAll(\PDO::FETCH_COLUMN);
     $rc = new \ReflectionClass($migrationsInstance);
     foreach ($rc->getMethods() as $method) {
         $method instanceof \ReflectionMethod;
         // if migration method not executed, run
         if (!in_array($method->name, $executed)) {
             // invoke the method
             try {
                 $method->invoke($migrationsInstance);
                 $failed = false;
             } catch (\Exception $e) {
                 // when sql error ...
                 $failed = true;
             }
             // save flag to migrations table
             Db::save('db_migrations', array('alias' => $method->name, 'failed' => $failed));
         }
     }
 }
Exemple #3
0
 public static function getGroupPages($groupId)
 {
     return Db::query("SELECT page FROM group_pages WHERE group_id = ?", array($groupId))->fetchAll(\PDO::FETCH_COLUMN);
 }