示例#1
0
 public function deleteSession($username)
 {
     $delete = new Delete();
     $adapter = $this->table_gateway->getAdapter();
     $delete->from('sessions')->where(array('username' => $username, 'session_id' => session_id()));
     $adapter->query($this->sql->buildSqlString($delete), $adapter::QUERY_MODE_EXECUTE);
     return true;
 }
示例#2
0
 /**
  * @covers Zend\Db\Sql\Delete::getSqlString
  */
 public function testGetSqlString()
 {
     $this->delete->from('foo')->where('x = y');
     $this->assertEquals('DELETE FROM "foo" WHERE x = y', $this->delete->getSqlString());
     // with TableIdentifier
     $this->delete = new Delete();
     $this->delete->from(new TableIdentifier('foo', 'sch'))->where('x = y');
     $this->assertEquals('DELETE FROM "sch"."foo" WHERE x = y', $this->delete->getSqlString());
 }
 public function unlink($userId, $addressId)
 {
     $adapter = $this->getDbAdapter();
     $statement = $adapter->createStatement();
     $where = new Where();
     $where->equalTo('user_id', $userId)->equalTo('address_id', $addressId);
     $delete = new Delete();
     $delete->from('user_addresses')->where($where);
     $delete->prepareStatement($adapter, $statement);
     $result = $statement->execute();
     return $result;
 }
示例#4
0
文件: Model.php 项目: gotcms/gotcms
 /**
  * Uninstall from module name
  *
  * @param AbstractModule $module Module
  * @param Model          $model  Module model
  *
  * @return boolean
  */
 public static function uninstall($module, $model)
 {
     if (empty($model) or !$module->uninstall()) {
         return false;
     }
     $select = new Sql\Select();
     $select->from('user_acl_permission')->columns(array('id'))->where->equalTo('permission', $model->getName());
     $userAclPermissionId = $model->fetchOne($select);
     $delete = new Sql\Delete();
     $delete->from('user_acl');
     $delete->where->equalTo('user_acl_permission_id', $userAclPermissionId);
     $model->execute($delete);
     $delete = new Sql\Delete();
     $delete->from('user_acl_permission');
     $delete->where->equalTo('id', $userAclPermissionId);
     $model->execute($delete);
     $model->delete();
     return true;
 }
示例#5
0
文件: Model.php 项目: gotcms/gotcms
 /**
  * Save document type model
  *
  * @return integer
  */
 public function save()
 {
     $this->events()->trigger(__CLASS__, 'before.save', $this);
     $arraySave = array('name' => $this->getName(), 'updated_at' => new Expression('NOW()'), 'description' => $this->getDescription(), 'icon_id' => $this->getIconId(), 'default_view_id' => $this->getDefaultViewId(), 'user_id' => $this->getUserId());
     try {
         $id = $this->getId();
         if (empty($id)) {
             $arraySave['created_at'] = new Expression('NOW()');
             $this->insert($arraySave);
             $this->setId($this->getLastInsertId());
         } else {
             $this->update($arraySave, array('id' => (int) $this->getId()));
         }
         $delete = new Sql\Delete();
         $delete->from('document_type_view');
         $delete->where(array('document_type_id' => (int) $this->getId()));
         $this->execute($delete);
         foreach ($this->views as $viewId) {
             if (empty($viewId)) {
                 continue;
             }
             $insert = new Sql\Insert();
             $insert->into('document_type_view')->values(array('document_type_id' => $this->getId(), 'view_id' => $viewId));
             $this->execute($insert);
         }
         $delete = new Sql\Delete();
         $delete->from('document_type_dependency');
         $delete->where->equalTo('parent_id', (int) $this->getId());
         $this->execute($delete);
         $dependencies = $this->getDependencies();
         if (!empty($dependencies)) {
             foreach ($dependencies as $childrenId) {
                 $insert = new Sql\Insert();
                 $insert->into('document_type_dependency')->values(array('parent_id' => $this->getId(), 'children_id' => $childrenId));
                 $this->execute($insert);
             }
         }
         $this->events()->trigger(__CLASS__, 'after.save', $this);
         return $this->getId();
     } catch (\Exception $e) {
         $this->events()->trigger(__CLASS__, 'after.save.failed', $this);
         throw new \Gc\Exception($e->getMessage(), $e->getCode(), $e);
     }
 }
 public function deleteData($table, $where)
 {
     $sql = new Sql($this->dbAdapter);
     $action = new Delete();
     $action->from($table);
     $action->where($where);
     $stmt = $sql->prepareStatementForSqlObject($action);
     $result = $stmt->execute();
     return $result;
 }