当前位置: 首页>>代码示例>>PHP>>正文


PHP QueryBuilder::update方法代码示例

本文整理汇总了PHP中QueryBuilder::update方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::update方法的具体用法?PHP QueryBuilder::update怎么用?PHP QueryBuilder::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QueryBuilder的用法示例。


在下文中一共展示了QueryBuilder::update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: editGroup

 public function editGroup(UserGroup $group)
 {
     if (empty($group->id) or !is_numeric($group->id)) {
         throw new InvalidArgumentException("Group id have to be non empty string");
     }
     if (empty($group->name)) {
         throw new InvalidArgumentException("Group name have to be non empty string");
     }
     $qb = new QueryBuilder();
     $qb->update(Tbl::get('TBL_GROUPS', 'UserManager'))->set(new Field('name'), $group->name)->set(new Field('description'), $group->description)->where($qb->expr()->equal(new Field('id'), $group->id));
     return $this->query->exec($qb->getSQL())->affected();
 }
开发者ID:Welvin,项目名称:stingle,代码行数:12,代码来源:UserGroupsManager.class.php

示例2: updateAttachmentMessageId

 public function updateAttachmentMessageId($attachmentId, $newMessageId)
 {
     if (empty($attachmentId) or !is_numeric($attachmentId)) {
         throw new InvalidIntegerArgumentException("\$attachmentId have to be non zero integer.");
     }
     if (empty($newMessageId) or !is_numeric($newMessageId)) {
         throw new InvalidIntegerArgumentException("\$newMessageId have to be non zero integer.");
     }
     $convMgr = Reg::get(ConfigManager::getConfig("Messaging", "Conversations")->Objects->ConversationManager);
     $filter = new ConversationMessagesFilter();
     $filter->setId($newMessageId);
     $message = $convMgr->getConversationMessage($filter);
     $qb = new QueryBuilder();
     $qb->update(Tbl::get('TBL_CONVERSATION_ATTACHEMENTS'))->set(new Field('message_id'), $message->id)->where($qb->expr()->equal(new Field('id'), $attachmentId));
     MySqlDbManager::getDbObject()->startTransaction();
     try {
         $convMgr->setMessageHasAttachment($message);
         $affected = $this->query->exec($qb->getSQL())->affected();
         if (!MySqlDbManager::getDbObject()->commit()) {
             MySqlDbManager::getDbObject()->rollBack();
         }
     } catch (Exception $e) {
         MySqlDbManager::getDbObject()->rollBack();
         throw $e;
     }
 }
开发者ID:Welvin,项目名称:stingle,代码行数:26,代码来源:ConversationAttachmentManager.class.php

示例3: updateYubikey

 /**
  * Update current yubikey
  * @param YubikeyObject $key
  * @throws YubikeyException
  * @return Ambigous <boolean, number>
  */
 public function updateYubikey(YubikeyObject $key)
 {
     if (empty($key)) {
         throw new YubikeyException("given yey object is empty");
     }
     $qb = new QueryBuilder();
     $qb->update(Tbl::get('TBL_KEYS', 'YubikeyUserAuthorization'))->set(new Field("key"), $key->key)->set(new Field("Description"), $key->description)->set(new Field("status"), $key->status)->where($qb->expr()->equal(new Field('id'), $key->id));
     return $this->query->exec($qb->getSQL())->affected();
 }
开发者ID:Welvin,项目名称:stingle,代码行数:15,代码来源:YubikeyManager.class.php

示例4: updateHost

 public static function updateHost(Host $host)
 {
     if (empty($host->id)) {
         throw new InvalidArgumentException("HostId is empty!");
     }
     $qb = new QueryBuilder();
     $qb->update(Tbl::get('TBL_HOSTS', 'Host'))->set(new Field('host'), $host->host)->set(new Field('subdomain'), $host->subdomain)->where($qb->expr()->equal(new Field('id'), $host->id));
     $sql = MySqlDbManager::getQueryObject();
     $sql->exec($qb->getSQL());
 }
开发者ID:Welvin,项目名称:stingle,代码行数:10,代码来源:HostManager.class.php

示例5: updateMap

 /**
  * Update aliase map of record with given id
  *
  * @param int $id alias Id
  * @param string $map new aliase map
  * @return bool
  */
 public function updateMap($id, $map)
 {
     if (empty($id) or !is_numeric($id)) {
         throw new InvalidArgumentException("\$id have to be non zero integer");
     }
     if (empty($map)) {
         throw new InvalidArgumentException("\$map have to be non empty string");
     }
     $qb = new QueryBuilder();
     $qb->update(Tbl::get('TBL_ALIAS'))->set(new Field('map'), $map)->where($qb->expr()->equal(new Field('id'), $id));
     $this->query->exec($qb->getSQL());
 }
开发者ID:Welvin,项目名称:stingle,代码行数:19,代码来源:RewriteAliasMap.class.php

示例6: updateGroup

 public function updateGroup(TextsGroup $group)
 {
     if (empty($group->id)) {
         throw new InvalidArgumentException("Group ID have to be specified");
     }
     if (!is_numeric($group->id)) {
         throw new InvalidArgumentException("Group ID have to be integer");
     }
     $qb = new QueryBuilder();
     $qb->update(Tbl::get('TBL_TEXTS_GROUPS'))->set(new Field('name'), $group->name)->where($qb->expr()->equal(new Field('id'), $group->id));
     $this->query->exec($qb->getSQL());
     return $this->query->affected();
 }
开发者ID:Welvin,项目名称:stingle,代码行数:13,代码来源:TextsGroupManager.class.php

示例7: validate

 /**
  * Validate given code using paramsArray
  * @param string $code
  * @param array $paramsArray
  * @return boolean
  */
 public function validate($code, $paramsArray = array())
 {
     if (empty($code)) {
         throw new InvalidArgumentException("Empty \$code supplied for validation!");
     }
     $qb = new QueryBuilder();
     $orX = new Orx();
     $orX->add($qb->expr()->isNull(new Field('valid_until')));
     $orX->add($qb->expr()->greaterEqual(new Field('valid_until'), new Func('NOW')));
     $qb->select(new Field('*'))->from(Tbl::get('TBL_ONE_TIME_CODES'))->where($qb->expr()->equal(new Field('code'), $code))->andWhere($orX);
     $this->query->exec($qb->getSQL());
     if ($this->query->countRecords() == 0) {
         return false;
     }
     $dbRow = $this->query->fetchRecord();
     $paramsArrayFromCode = $this->getArrayFromCode($dbRow['code']);
     if ($paramsArrayFromCode === false) {
         return false;
     }
     $resultingArray = array_diff_assoc($paramsArray, $paramsArrayFromCode);
     if (count($resultingArray) != 0) {
         return false;
     }
     if ($dbRow['multi'] == '1') {
         if ($dbRow['usage_limit'] > 0) {
             $qb = new QueryBuilder();
             if ($dbRow['usage_count'] < $dbRow['usage_limit']) {
                 $qb->update(Tbl::get('TBL_ONE_TIME_CODES'))->set(new Field('usage_count'), $qb->expr()->sum(new Field('usage_count'), 1))->where($qb->expr()->equal(new Field('id'), $dbRow['id']));
                 $this->query->exec($qb->getSQL());
             } else {
                 $qb->delete(Tbl::get('TBL_ONE_TIME_CODES'))->where($qb->expr()->equal(new Field("id"), $dbRow['id']));
                 $this->query->exec($qb->getSQL());
                 return false;
             }
         }
     } else {
         $qb = new QueryBuilder();
         $qb->delete(Tbl::get('TBL_ONE_TIME_CODES'))->where($qb->expr()->equal(new Field("id"), $dbRow['id']));
         $this->query->exec($qb->getSQL());
     }
     return true;
 }
开发者ID:Welvin,项目名称:stingle,代码行数:48,代码来源:OneTimeCodes.class.php

示例8: attempt

 public static function attempt(array $credentials, $remember_me = false)
 {
     $input_email = filter_var($credentials['email'], FILTER_SANITIZE_STRING);
     $input_password = filter_var($credentials['pass'], FILTER_SANITIZE_STRING);
     //run validation
     $v = new Validator($credentials);
     $v->rule('email', 'email')->message('Please provide an valid Email address');
     $v->rule('required', 'email')->message('Email is required');
     $v->rule('required', 'pass')->message('Please provide an password');
     if (!$v->validate()) {
         return array('errors' => $v->errors());
     }
     //data valid so proceed to next
     try {
         $m = new \QueryBuilder();
         $user = $m->select('users', array('email = :email', array('email' => array($input_email, \PDO::PARAM_STR))));
         if (!$user) {
             throw new \Exception('No user found with this credential', 5002);
         }
         $stored_password_hash = $user['password'];
         if (password_verify($input_password, $stored_password_hash)) {
             $_SESSION['auth.user.logged_in'] = true;
             $_SESSION['auth.user.id'] = $user['id'];
             if ($remember_me === true) {
                 $auth_config = load_config('auth');
                 //set token and it's validity period
                 $remember_token = uniqid('rem_');
                 $remember_validity = time() + $auth_config['login_cookie_expire'];
                 $m->update('users', array('remember_token' => array($remember_token, \PDO::PARAM_STR), 'token_validity' => array(date('Y-m-d H:i:s', $remember_validity), \PDO::PARAM_STR)), array('id = :id', array('id' => array(intval($user['id']), \PDO::PARAM_INT))));
                 setcookie($auth_config['login_cookie_name'], $remember_token, $remember_validity);
             }
             return true;
         } else {
             throw new \Exception('Invalid credential. Please provide valid username and password.', 5003);
         }
     } catch (\Exception $ex) {
         throw $ex;
     }
 }
开发者ID:nscreed,项目名称:base_raw_approach,代码行数:39,代码来源:Auth.php

示例9: declinePhoto

 public function declinePhoto(UserPhoto $photo)
 {
     if (empty($photo->id)) {
         throw new InvalidArgumentException("UserPhoto object has no id!");
     }
     if (empty($photo->userId)) {
         $photo = $this->getPhoto($photo->id);
     }
     $qb = new QueryBuilder();
     $qb->update(Tbl::get('TBL_USERS_PHOTOS'))->set(new Field('status'), static::MODERATION_STATUS_DECLINED)->set(new Field('modification_date'), new Func('NOW'))->where($qb->expr()->equal(new Field('id'), $photo->id));
     $this->query->exec($qb->getSQL());
     $this->correctDefaultPhoto($photo->userId);
 }
开发者ID:Welvin,项目名称:stingle,代码行数:13,代码来源:UserPhotoManager.class.php

示例10: save

 public function save()
 {
     if (empty($this->modified_data) && !$this->new) {
         return true;
     }
     if ($this->validate()) {
         $data = array_intersect_key($this->data, array_flip(static::$fields));
         if ($this->new) {
             $sql = QueryBuilder::insert(get_called_class());
             $sql->values($data);
         } else {
             $pk = static::$primary_key;
             $data = array_intersect_key($data, array_flip($this->modified_data));
             $sql = QueryBuilder::update(get_called_class());
             $sql->set($data);
             $sql->where(array($pk => $this->{$pk}));
         }
         if (method_exists($this, 'before_save')) {
             if (!$this->before_save($sql)) {
                 $this->errors[] = "before_save failed";
                 return false;
             }
         }
         if (!$sql->execute()) {
             $this->error[] = "Save failed on SQL-Level!";
             return false;
         }
         if (method_exists($this, 'after_create') && $this->new) {
             $this->after_create();
         } elseif (method_exists($this, 'after_update')) {
             $this->after_update();
         }
         if (method_exists($this, 'after_save')) {
             $this->after_save();
         }
         return true;
     } else {
         $this->errors[] = "validation failed";
         return false;
     }
 }
开发者ID:dreamblazenet,项目名称:sqls,代码行数:41,代码来源:DatabaseObject.php

示例11: lockJob

 /**
  * Lock job queue for working on current job
  * Helper funcion
  * @access private
  * @param JobQueueObj $job
  * @return TRUE|FALSE
  */
 private function lockJob(JobQueueObj $job)
 {
     if (!is_numeric($job->id)) {
         throw JobQueueException("Job id is not numeric!");
     }
     $qb = new QueryBuilder();
     $qb->update(TBL::get('TBL_JOB_QUEUE'))->set(new Field('status'), self::JOB_STATUS_IN_PROCESS)->set(new Field('start_date'), new Func('NOW'))->where($qb->expr()->equal(new Field('id'), $job->id));
     return $this->query->exec($qb->getSQL())->affected();
 }
开发者ID:Welvin,项目名称:stingle,代码行数:16,代码来源:JobQueueManager.class.php

示例12: updateQueryString

 private static function updateQueryString(array $pageInfo, $id)
 {
     $qb = new QueryBuilder();
     $qb->update(Tbl::get('TBL_PAGE_INFO', 'PageInfo'))->set(new Field('title'), $pageInfo['title'])->set(new Field('meta_keywords'), $pageInfo['keywords'])->set(new Field('meta_description'), $pageInfo['description'])->where($qb->expr()->equal(new Field('id'), $id));
     return $qb->getSQL();
 }
开发者ID:Welvin,项目名称:stingle,代码行数:6,代码来源:PageInfoManager.class.php

示例13: testUpdate

 /**
  * Generated from @assert update('user')->set(array('key1'=>'value1', 'key2'=>2))->where(array(array('id', 1), array('id', 1)))->text() [==] "UPDATE `user` SET `key1`=:Skey1, `key2`=:Skey2 WHERE `id` = 1 AND `id` = 1".
  *
  * @covers Kotchasan\Database\QueryBuilder::update
  */
 public function testUpdate()
 {
     $this->assertEquals("UPDATE `user` SET `key1`=:Skey1, `key2`=:Skey2 WHERE `id` = 1 AND `id` = 1", $this->object->update('user')->set(array('key1' => 'value1', 'key2' => 2))->where(array(array('id', 1), array('id', 1)))->text());
 }
开发者ID:goragod,项目名称:kotchasan,代码行数:9,代码来源:QueryBuilderTest.php

示例14: changeConversationHasAttachmentStatus

 public function changeConversationHasAttachmentStatus($uuid, $status, $userId = null)
 {
     if (empty($uuid) or !is_numeric($uuid)) {
         throw new InvalidIntegerArgumentException("\$uuid have to be non zero integer.");
     }
     if (!is_numeric($status) or !in_array($status, $this->getConstsArray("STATUS_HAS_ATTACHMENT"))) {
         throw new InvalidIntegerArgumentException("Invalid \$status specified");
     }
     if ($userId !== null and (empty($userId) or !is_numeric($userId))) {
         throw new InvalidIntegerArgumentException("\$userId have to be non zero integer.");
     }
     $qb = new QueryBuilder();
     $qb->update(Tbl::get('TBL_CONVERSATIONS'))->set(new Field('has_attachment'), $status)->where($qb->expr()->equal(new Field('uuid'), $uuid));
     if ($userId !== null and !empty($userId) and is_numeric($userId)) {
         $qb->andWhere($qb->expr()->equal(new Field('user_id'), $userId));
     }
     $this->query->exec($qb->getSQL());
     $hookParams = array('type' => 'hasAttach', 'uuid' => $uuid, 'hasAttach' => $status);
     HookManager::callHook("ConversationUpdate", $hookParams);
 }
开发者ID:Welvin,项目名称:stingle,代码行数:20,代码来源:ConversationManager.class.php

示例15: setHostsDefaultLanguage

 public static function setHostsDefaultLanguage(Host $host, Language $language)
 {
     $sql = MySqlDbManager::getQueryObject();
     $qb = new QueryBuilder();
     $qb->update(Tbl::get('TBL_HOST_LANGUAGE'))->set(new Field("default"), 0)->where($qb->expr()->equal(new Field('host_id'), $host->id));
     $sql->exec($qb->getSQL());
     $qb = new QueryBuilder();
     $qb->update(Tbl::get('TBL_HOST_LANGUAGE'))->set(new Field("default"), 1)->where($qb->expr()->equal(new Field('host_id'), $host->id))->andWhere($qb->expr()->equal(new Field('lang_id'), $language->id));
     $sql->exec($qb->getSQL());
 }
开发者ID:Welvin,项目名称:stingle,代码行数:10,代码来源:HostLanguageManager.class.php


注:本文中的QueryBuilder::update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。