Esempio n. 1
0
 /**
  * {@inheritdoc}
  *
  * @param null $sequence
  * @return integer|string|array
  */
 public function execute($sequence = null)
 {
     $result = Db::query($this->getSQL(), $this->params, $this->types);
     if ($result) {
         return Db::handler()->lastInsertId($sequence);
     }
     return $result;
 }
Esempio n. 2
0
 /**
  * Execute this query using the bound parameters and their types
  *
  * @return integer|string|array
  */
 public function execute()
 {
     return Db::query($this->getSql(), $this->params, $this->types);
 }
Esempio n. 3
0
 /**
  * Deletes existing rows
  *
  * <code>
  *     Table::delete(['login' => 'Man'])
  * </code>
  *
  * @param  array $where An array of SQL WHERE clause(s)
  * @return integer The number of rows deleted
  * @throws Exception\DbException
  */
 public static function delete(array $where)
 {
     if (!sizeof($where)) {
         throw new DbException("Method `Table::delete()` can't delete all records in table,\n" . "please use `Db::query()` instead (of cause if you know what are you doing)");
     }
     $self = static::getInstance();
     $where = $self->filterColumns($where);
     if (!sizeof($where)) {
         throw new DbException("Invalid field names of table `{$self->table}`. Please check use of `delete()` method");
     }
     $table = DbProxy::quoteIdentifier($self->table);
     $sql = "DELETE FROM {$table}" . " WHERE " . join(' AND ', self::prepareStatement($where));
     return DbProxy::query($sql, array_values($where));
 }
Esempio n. 4
0
use Bluz\Proxy\Cache;
use Bluz\Proxy\Db;
use Bluz\Proxy\Messages;
return function ($acl) use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    $callback = function () use($acl) {
        /**
         * @var Bootstrap $this
         */
        Db::query('DELETE FROM acl_privileges');
        foreach ($acl as $roleId => $modules) {
            foreach ($modules as $module => $privileges) {
                foreach ($privileges as $privilege => $flag) {
                    Db::query('INSERT INTO acl_privileges SET roleId = ?, module = ?, privilege = ?', array($roleId, $module, $privilege));
                }
            }
        }
    };
    if (empty($acl)) {
        Messages::addError('Privileges set is empty. You can\'t remove all of them');
    } elseif (Db::transaction($callback)) {
        Cache::deleteByTag('privileges');
        Messages::addSuccess('All data was saved');
    } else {
        Messages::addError('Internal Server Error');
    }
    $this->redirectTo('acl', 'index');
};