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


PHP Query::generateUpdateStm方法代码示例

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


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

示例1: update

 function update($contact, $editor)
 {
     parent::update($resource, $editor, self::OBJECT_CLASS);
     $old = $this->quickLoad($resource->getID());
     if (is_null($r_old)) {
         throw new Exception("L'oggetto da modificare non esiste.");
     }
     $data = array();
     if ($contact->getContact() != $old->getContact()) {
         $data[DB::CONTACT_CONTACT] = $contact->getContact();
     }
     if ($contact->getName() != $old->getName()) {
         $data[DB::CONTACT_NAME] = $contact->getName();
     }
     $this->db->execute($s = Query::generateUpdateStm($this->table, $data, array(new WhereConstraint($this->table->getColumn(DB::CONTACT_ID), Operator::EQUAL, $contact->getID()))), $this->table->getName(), $contact);
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore aggiornando il dato. Riprovare.");
     }
     return $contact;
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:20,代码来源:ContactDao.php

示例2: update

 function update($user, $editor)
 {
     parent::update($user, $editor, self::OBJECT_CLASS);
     $old = $this->quickLoad($user->getID());
     if (is_null($old)) {
         throw new Exception("L'oggetto da modificare non esiste.");
     }
     $data = array();
     if ($user->getAvatar() != $old->getAvatar()) {
         $data[DB::USER_AVATAR] = $user->getAvatar();
     }
     if ($user->getBirthday() != $old->getBirthday()) {
         $data[DB::USER_BIRTHDAY] = $user->getBirthday();
     }
     if ($user->getBirthplace() != $old->getBirthplace()) {
         $data[DB::USER_BIRTHPLACE] = $user->getBirthplace();
     }
     if ($user->getEMail() != $old->getEMail()) {
         $data[DB::USER_E_MAIL] = $user->getEMail();
     }
     if ($user->getGender() != $old->getGender()) {
         $data[DB::USER_GENDER] = $user->getGender();
     }
     if ($user->getHobbies() != $old->getHobbies()) {
         $data[DB::USER_HOBBIES] = $user->getHobbies();
     }
     if ($user->getJob() != $old->getJob()) {
         $data[DB::USER_JOB] = $user->getJob();
     }
     if ($user->getLivingPlace() != $old->getLivingPlace()) {
         $data[DB::USER_LIVINGPLACE] = $user->getLivingPlace();
     }
     if ($user->getName() != $old->getName()) {
         $data[DB::USER_NAME] = $user->getName();
     }
     if ($user->getNickname() != $old->getNickname()) {
         $data[DB::USER_NICKNAME] = $user->getNickname();
     }
     if ($user->getPassword() != $old->getPassword()) {
         $data[DB::USER_PASSWORD] = $user->getPassword();
     }
     if ($user->getRole() != $old->getRole()) {
         $data[DB::USER_ROLE] = $user->getRole();
     }
     if ($user->getSurname() != $old->getSurname()) {
         $data[DB::USER_SURNAME] = $user->getSurname();
     }
     if ($user->getVisible() != $old->getVisible()) {
         $data[DB::USER_VISIBLE] = $user->getVisible() ? 1 : 0;
     }
     $this->db->execute($s = Query::generateUpdateStm($this->table, $data, array(new WhereConstraint($this->table->getColumn(DB::USER_ID), Operator::EQUAL, $user->getID()))), $this->table->getName(), $user);
     //TODO aggiungere authenitcationManager
     //aggiorno lo stato della risorsa (se chi l'ha modificata è un redattore).
     //if(AuthenticationManager::isUserManager($editor)) {
     //	$resource->setEditable(false);
     //	$resource->setRemovable(false);
     //	$this->updateState($resource);
     //}
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore aggiornando il dato. Riprovare.");
     }
     return $user;
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:63,代码来源:UserDao.php

示例3: updateState

 protected function updateState($object, $table, $id_column_name)
 {
     if (is_null($object)) {
         throw new Exception("Attenzione! Non hai inserito l'oggetto da modificare.");
     }
     $this->checkConnection();
     $old = $this->quickLoad($object->getID());
     if (is_null($old)) {
         throw new Exception("L'oggetto da modificare non esiste.");
     }
     $data = array();
     if (is_a($object, "Writable") || is_subclass_of($object, "Writable")) {
         if ($object->hasAutoBlackContent() != $old->hasAutoBlackContent()) {
             $data[DB::AUTO_BLACK_CONTENT] = $object->hasAutoBlackContent();
         }
         if ($object->hasBlackContent() != $old->hasBlackContent()) {
             $data[DB::BLACK_CONTENT] = $object->hasBlackContent();
         }
         if ($object->hasYellowContent() != $old->hasYellowContent()) {
             $data[DB::YELLOW_CONTENT] = $object->hasYellowContent();
         }
         if ($object->hasRedContent() != $old->hasRedContent()) {
             $data[DB::RED_CONTENT] = $object->hasRedContent();
         }
     }
     if (is_a($object, "Editable") || is_subclass_of($object, "Editable")) {
         if ($object->getPreviousVersion() > $old->getPreviousVersion()) {
             $data[DB::PREVIOUS_VERSION] = $object->getPreviousVersion();
         }
         if ($object->isEditable() != $old->isEditable()) {
             $data[DB::EDITABLE] = $object->isEditable();
         }
         if ($object->isRemovable() != $old->isRemovable()) {
             $data[DB::REMOVABLE] = $object->isRemovable();
         }
     }
     if (count($data) == 0) {
         return $object;
     }
     $this->db->execute(Query::generateUpdateStm($table, $data, new WhereConstraint($table->getColumn($id_column_name), Operator::EQUAL, $object->getID())), null, LOGMANAGER);
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore aggiornando il dato. Riprovare.");
     }
     return $object;
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:45,代码来源:Dao.php

示例4: update

 function update($post, $editor)
 {
     parent::update($post, $editor, self::OBJECT_CLASS);
     if (!AuthorizationManager::canUserDo(DB::EDIT_POST, $object)) {
         throw new Exception("L'utente non è autorizzato ad effettuare questa operazione.");
     }
     $p_old = $this->quickLoad($post->getID());
     $data = array();
     if (is_null($p_old)) {
         throw new Exception("L'oggetto da modificare non esiste.");
     }
     //cerco le differenze e le salvo.
     if ($p_old->getTitle() != $post->getTitle()) {
         $data[DB::POST_TITLE] = $post->getTitle();
     }
     if ($p_old->getSubtitle() != $post->getSubtitle()) {
         $data[DB::POST_SUBTITLE] = $post->getSubtitle();
     }
     if ($p_old->getHeadline() != $post->getHeadline()) {
         $data[DB::POST_HEADLINE] = $post->getHeadline();
     }
     if ($p_old->getContent() != $post->getContent()) {
         if ($post->type == Post::NEWS || $post->type == Post::VIDEOREP) {
             $data[DB::POST_CONTENT] = $post->getContent();
         } else {
             $data[DB::POST_CONTENT] = serialize($post->getContent());
         }
     }
     if ($p_old->getPlace() != $post->getPlace()) {
         $data[DB::POST_PLACE] = $post->getPlace();
     }
     if ($p_old->getPlaceName() != $post->getPlaceName()) {
         $data[DB::POST_PLACE_NAME] = $post->getPlaceName();
     }
     if ($p_old->getTags() != $post->getTags()) {
         $data[DB::POST_TAGS] = $post->getTags();
     }
     if ($p_old->getCategories() != $post->getCategories()) {
         // check sulle categorie, eliminazione di quelle che non esistono nel sistema, se vuoto inserimento di quella di default
         require_once 'manager/CategoryManager.php';
         $new_cat = CategoryManager::filterWrongCategories(explode(",", $post->getCategories()));
         if (count($new_cat) == 0) {
             $new_cat[] = self::DEFAULT_CATEGORY;
         }
         $post->setCategories(Filter::arrayToText($new_cat));
         $data[DB::POST_CATEGORIES] = $post->getCategories();
     }
     if ($p_old->isVisible() !== $post->isVisible()) {
         $data[DB::POST_VISIBLE] = $post->isVisible() ? 1 : 0;
     }
     if ($p_old->getPermalink() != $post->getPermalink()) {
         if ($this->permalinkExists($post->getPermalink())) {
             throw new Exception("Il permalink inserito esiste già. Riprova.");
         }
         $data[DB::POST_PERMALINK] = $post->getPermalink();
     }
     if (count($data) == 0) {
         throw new Exception("Nessuna modifica da effettuare.");
     }
     $modDate = $_SERVER["REQUEST_TIME"];
     $data[DB::POST_MODIFICATION_DATE] = date("Y/m/d G:i:s", $modDate);
     // se mi dicono di fare l'update, cambio modificationDate
     //salvo la versione precedente e ne tengo traccia.
     $history_id = $this->saveHistory($p_old, "UPDATED");
     $post->setPreviousVersion($history_id);
     $data[DB::POST_PREVIOUS_VERSION] = $post->getPreviousVersion();
     $rs = $this->db->execute($s = Query::generateUpdateStm($this->table, $data, array(new WhereConstraint($this->table->getColumn(DB::POST_ID), Operator::EQUAL, $post->getID()))), $this->table->getName(), $post);
     //aggiorno lo stato del post (se chi l'ha modificato è un redattore).
     if (AuthenticationManager::isEditor($editor)) {
         $post->setEditable(false);
         $post->setRemovable(false);
         $this->updateState($post);
     }
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore aggiornando il dato. Riprovare.");
     }
     //salvo i tag che non esistono
     if (isset($data[DB::POST_TAGS]) && !is_null($data[DB::POST_TAGS]) && trim($data[DB::POST_TAGS]) != "") {
         require_once 'manager/TagManager.php';
         TagManager::createTags(explode(",", $data[DB::POST_TAGS]));
         //TODO
     }
     return $post->setModificationDate($modDate);
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:84,代码来源:PostDao.php

示例5: getAccessCount

 /**
  * @deprecated
  * Enter description here ...
  * @param unknown_type $type
  * @param unknown_type $id
  */
 static function getAccessCount($type, $id)
 {
     if ($type == null || $type == "" || $id == null) {
         return 0;
     }
     $db = new DBManager();
     if (!$db->connect_errno()) {
         define_tables();
         defineLogColumns();
         $table = Query::getDBSchema()->getTable("AccessLog");
         $exists = false;
         if ($type == "Post") {
             require_once 'post/PostManager.php';
             return 0;
             $exists = PostManager::postExists($id);
         } else {
             if ($type == "User") {
                 require_once 'user/UserManager.php';
                 return 0;
                 $exists = UserManager::userExists($id);
             } elseif ($type == "Partner") {
                 //TODO: implementa Partner
                 //				require_once 'post/PartnerManager.php';
                 //				$exists = PartnerManager::partnerExists($id);
             }
         }
         if ($exists) {
             $wheres = array(new WhereConstraint($table->getColumn("alog_type"), Operator::EQUAL, $type), new WhereConstraint($table->getColumn("alog_id"), Operator::EQUAL, $id));
             $db->execute($s = Query::generateSelectStm(array($table), array(), $wheres, array()));
             if ($db->num_rows() == 1) {
                 $row = $db->fetch_result();
                 $data = array("alog_count" => ++$row["alog_count"]);
                 $db->execute($s = Query::generateUpdateStm($table, $data, $wheres), null, LOGMANAGER);
                 if ($db->affected_rows() == 1) {
                     return $row["alog_count"];
                 }
             } else {
                 $data = array("alog_type" => $type, "alog_id" => $id);
                 $db->execute($s = Query::generateInsertStm($table, $data));
                 if ($db->affected_rows() == 1) {
                 }
                 return 1;
             }
         }
         return 0;
     }
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:53,代码来源:LogManager.php

示例6: update

 function update()
 {
     $old = self::loadFromDatabase($this->getID());
     require_once "query.php";
     $db = new DBManager();
     if (!$db->connect_errno()) {
         define_tables();
         defineUserColumns();
         $table = Query::getDBSchema()->getTable(TABLE_USER);
         $data = array();
         if ($this->getAvatar() != $old->getAvatar()) {
             $data[USER_AVATAR] = $this->getAvatar();
         }
         if ($this->getBirthday() != $old->getBirthday()) {
             $data[USER_BIRTHDAY] = $this->getBirthday();
         }
         if ($this->getBirthplace() != $old->getBirthplace()) {
             $data[USER_BIRTHPLACE] = $this->getBirthplace();
         }
         if ($this->getEMail() != $old->getEMail()) {
             $data[USER_E_MAIL] = $this->getEMail();
         }
         if ($this->getGender() != $old->getGender()) {
             $data[USER_GENDER] = $this->getGender();
         }
         if ($this->getHobbies() != $old->getHobbies()) {
             $data[USER_HOBBIES] = $this->getHobbies();
         }
         if ($this->getJob() != $old->getJob()) {
             $data[USER_JOB] = $this->getJob();
         }
         if ($this->getLivingPlace() != $old->getLivingPlace()) {
             $data[USER_LIVINGPLACE] = $this->getLivingPlace();
         }
         if ($this->getName() != $old->getName()) {
             $data[USER_NAME] = $this->getName();
         }
         if ($this->getNickname() != $old->getNickname()) {
             $data[USER_NICKNAME] = $this->getNickname();
         }
         if ($this->getPassword() != $old->getPassword()) {
             $data[USER_PASSWORD] = $this->getPassword();
         }
         if ($this->getRole() != $old->getRole()) {
             $data[USER_ROLE] = $this->getRole();
         }
         if ($this->getSurname() != $old->getSurname()) {
             $data[USER_SURNAME] = $this->getSurname();
         }
         if ($this->getVisible() != $old->getVisible()) {
             $data[USER_VISIBLE] = $this->getVisible() ? 1 : 0;
         }
         $db->execute($s = Query::generateUpdateStm($table, $data, array(new WhereConstraint($table->getColumn(USER_ID), Operator::EQUAL, $this->getID()))), $table->getName(), $this);
         //echo "<p>" . $db->affected_rows() . $s . "</p>"; // DEBUG
         if ($db->affected_rows() == 1) {
             return $this;
         } else {
             $db->display_error("User::update()");
         }
     } else {
         $db->display_connect_error("User::update()");
     }
     return false;
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:64,代码来源:User.php

示例7: delete

 function delete()
 {
     if ($this->getName() == MAILBOX) {
         return false;
     }
     //la mailbox non si può eliminare.
     require_once "query.php";
     $db = new DBManager();
     if (!$db->connect_errno()) {
         define_tables();
         defineMailDirColumns();
         $table = Query::getDBSchema()->getTable(TABLE_MAIL_DIRECTORY);
         //cerco la Mailbox dell'utente e sposto tutte le mail lì.
         $db->execute($s = Query::generateSelectStm(array($table), array(), array(new WhereConstraint($table->getColumn(MAIL_DIRECTORY_OWNER), Operator::EQUAL, $this->owner), new WhereConstraint($table->getColumn(MAIL_DIRECTORY_NAME), Operator::EQUAL, MAILBOX)), array()), $table->getName(), $this);
         if ($db->num_rows() == 1) {
             $row = $db->fetch_result();
             $mailboxid = intval($row[MAIL_DIRECTORY_ID]);
             $table1 = Query::getDBSchema()->getTable(TABLE_MAIL_IN_DIRECTORY);
             $db->execute($s = Query::generateUpdateStm($table1, array(MAIL_IN_DIRECTORY_DIRECTORY => intval($mailboxid)), array(new WhereConstraint($table1->getColumn(MAIL_IN_DIRECTORY_DIRECTORY), Operator::EQUAL, $this->getID()))), $table1->getName(), $this);
             if ($db->affected_rows() == count($this->getMails())) {
                 $rs = $db->execute($s = Query::generateDeleteStm($table, array(new WhereConstraint($table->getColumn(MAIL_DIRECTORY_ID), Operator::EQUAL, $this->getID()))), $table->getName(), $this);
                 //echo "<br />" . $db->affected_rows() . $s; //DEBUG
                 if ($db->affected_rows() == 1) {
                     return $this;
                 } else {
                     $db->display_error("MailDirectory::delete()");
                 }
             } else {
                 $db->display_error("MailDirectory::delete()");
             }
         } else {
             $db->display_error("MailDirectory::delete()");
         }
     } else {
         $db->display_connect_error("MailDirectory::delete()");
     }
     return false;
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:38,代码来源:Mail.php

示例8: update

 /**
  * Aggiorna il post e le sue dipendenze nel database.
  * Le dipendenze aggiornate sono quelle che dipendono dall'autore ovvero: tag e categorie
  * Potrebbe salvare alcune tuple in Tag.
  *
  * @return: modificationDate o FALSE se c'è un errore.
  */
 function update()
 {
     require_once "query.php";
     $db = new DBManager();
     if (!$db->connect_errno()) {
         define_tables();
         definePostColumns();
         $table = Query::getDBSchema()->getTable(TABLE_POST);
         $rs = $db->execute($s = Query::generateSelectStm(array($table), array(), array(new WhereConstraint($table->getColumn(POST_ID), Operator::EQUAL, $this->getID())), array()), $table->getName(), $this);
         //echo "<br />" . $s; //DEBUG
         $data = array();
         if ($db->num_rows() == 1) {
             $row = $db->fetch_result();
             //cerco le differenze e le salvo.
             if ($row[POST_TITLE] != $this->getTitle()) {
                 $data[POST_TITLE] = $this->getTitle();
             }
             if ($row[POST_SUBTITLE] != $this->getSubtitle()) {
                 $data[POST_SUBTITLE] = $this->getSubtitle();
             }
             if ($row[POST_HEADLINE] != $this->getHeadline()) {
                 $data[POST_HEADLINE] = $this->getHeadline();
             }
             if ($row[POST_CONTENT] != $this->getContent()) {
                 if ($this->type == "post" || $this->type == "news" || $this->type == "videoreportage") {
                     $data[POST_CONTENT] = $this->getContent();
                 } else {
                     $data[POST_CONTENT] = serialize($this->getContent());
                 }
             }
             if ($row[POST_PLACE] != $this->getPlace()) {
                 $data[POST_PLACE] = $this->getPlace();
             }
             if ($row[POST_TAGS] != $this->getTags()) {
                 $data[POST_TAGS] = $this->getTags();
             }
             if ($row[POST_CATEGORIES] != $this->getCategories()) {
                 // check sulle categorie, eliminazione di quelle che non esistono nel sistema, se vuoto inserimento di quella di default
                 $new_cat = CategoryManager::filterWrongCategories(explode(",", $this->getCategories()));
                 if (count($new_cat) == 0) {
                     $new_cat[] = self::DEFAULT_CATEGORY;
                 }
                 $this->setCategories(Filter::arrayToText($new_cat));
                 $data[POST_CATEGORIES] = $this->getCategories();
             }
             settype($row[POST_VISIBLE], "boolean");
             if ($row[POST_VISIBLE] !== $this->isVisible()) {
                 $data[POST_VISIBLE] = $this->isVisible() ? 1 : 0;
             }
             if ($row[POST_PERMALINK] != $this->getPermalink()) {
                 if (self::permalinkExists($this->getPermalink())) {
                     return false;
                 }
                 $data[POST_PERMALINK] = $this->getPermalink();
             }
             if (count($data) == 0) {
                 return $this->getModificationDate();
             }
             $data[POST_MODIFICATION_DATE] = date("Y/m/d G:i:s", $_SERVER["REQUEST_TIME"]);
             // se mi dicono di fare l'update, cambio modificationDate
             //echo "<br />" . serialize($data); //DEBUG
             $rs = $db->execute($s = Query::generateUpdateStm($table, $data, array(new WhereConstraint($table->getColumn(POST_ID), Operator::EQUAL, $this->getID()))), $table->getName(), $this);
             //echo "<br />" . $s; //DEBUG
             //echo "<br />" . mysql_affected_rows(); //DEBUG
             if ($db->affected_rows() == 1) {
                 //salvo i tag che non esistono
                 if (isset($data[POST_TAGS]) && !is_null($data[POST_TAGS]) && trim($data[POST_TAGS]) != "") {
                     TagManager::createTags(explode(",", $data[POST_TAGS]));
                 }
                 //echo "<br />" . $this; //DEBUG
                 return $this->getModificationDate();
             } else {
                 $db->display_error("Post::update()");
             }
         } else {
             $db->display_error("Post::update()");
         }
     } else {
         $db->display_connect_error("Post::update()");
     }
     return false;
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:89,代码来源:Post.php

示例9: update

 /**
  * Aggiorna il post e le sue dipendenze nel database.
  * Le dipendenze aggiornate sono quelle che dipendono dall'autore ovvero: tag e categorie
  * Potrebbe salvare alcune tuple in Tag.
  *
  * @return: $this o FALSE se c'è un errore.
  */
 function update()
 {
     $old = Contest::loadFromDatabase($this->getID());
     $data = array();
     if ($old->getTitle() != $this->getTitle()) {
         $data[CONTEST_TITLE] = $this->getTitle();
     }
     if ($old->getDescription() != $this->getDescription()) {
         $data[CONTEST_DESCRIPTION] = $this->getDescription();
     }
     if ($old->getEnd() != $this->getEnd()) {
         $data[CONTEST_END] = $this->getEnd();
     }
     if ($old->getPrizes() != $this->getPrizes()) {
         $data[CONTEST_PRIZES] = $this->getPrizes();
     }
     if ($old->getRules() != $this->getRules()) {
         $data[CONTEST_RULES] = $this->getRules();
     }
     if ($old->getStart() != $this->getStart()) {
         $data[CONTEST_START] = $this->getStart();
     }
     if ($old->getWinners() != $this->getWinners()) {
         $data["ct_winners"] = $this->getWinners();
     }
     //TODO aggiornare i vincitori.
     if ($old->getSubscriberType() == $this->getSubscriberType()) {
         $data[CONTEST_TYPE_OF_SUBSCRIBER] = $this->getSubscriberType();
     }
     require_once "query.php";
     $db = new DBManager();
     if (!$db->connect_errno()) {
         $table = Query::getDBSchema()->getTable(TABLE_CONTEST);
         $rs = $db->execute($s = Query::generateUpdateStm($table, $data, array(new WhereConstraint($table->getColumn(CONTEST_ID), Operator::EQUAL, $this->getID()))), $table->getName(), $this);
         //echo "<br />" . $s; //DEBUG
         //echo "<br />" . mysql_affected_rows(); //DEBUG
         if ($db->affected_rows() == 1) {
             //echo "<br />" . $this; //DEBUG
             return $this->getID();
         } else {
             $db->display_error("Contest::update()");
         }
     } else {
         $db->display_connect_error("Contest::update()");
     }
     return false;
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:54,代码来源:Contest.php

示例10: addWinner

 function addWinner($post, $contest, $position)
 {
     parent::update($contest, self::OBJECT_CLASS);
     if (!is_subclass_of($post, "Post")) {
         throw new Exception("Attenzione! Il parametro di ricerca non è un post.");
     }
     $this->db->execute($s = Query::generateUpdateStm($this->table_cs, array(DB::CONTEST_SUBSCRIBER_PLACEMENT => intval($position)), array(new WhereConstraint($this->table_cs->getColumn(DB::CONTEST_SUBSCRIBER_POST), Operator::EQUAL, $post->getID()), new WhereConstraint($this->table_cs->getColumn(DB::CONTEST_SUBSCRIBER_CONTEST), Operator::EQUAL, $contest->getID()))), $table->getName(), $contest);
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore aggiornando l'oggetto. Riprovare.");
     }
     return $contest;
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:12,代码来源:ContestDao.php

示例11: update

 function update($resource, $editor)
 {
     parent::update($resource, $editor, self::OBJECT_CLASS);
     $r_old = $this->quickLoad($resource->getID());
     if (is_null($r_old)) {
         throw new Exception("L'oggetto da modificare non esiste.");
     }
     $data = array();
     //cerco le differenze POSSIBILI e le salvo.
     if ($r_old->getDescription() != $resource->getDescription()) {
         $data[DB::RESOURCE_DESCRIPTION] = $resource->getDescription();
     }
     if ($r_old->getTags() != $resource->getTags()) {
         $data[DB::RESOURCE_TAGS] = $resource->getTags();
     }
     $modDate = $_SERVER["REQUEST_TIME"];
     $data[DB::RESOURCE_MODIFICATION_DATE] = date("Y/m/d G:i:s", $modDate);
     //salvo la versione precedente e ne tengo traccia.
     $history_id = $this->saveHistory($r_old, $editor, "UPDATED");
     $resource->setPreviousVersion($history_id);
     $data[DB::PREVIOUS_VERSION] = $resource->getPreviousVersion();
     $rs = $this->db->execute($s = Query::generateUpdateStm($this->table, $data, array(new WhereConstraint($this->table->getColumn(DB::RESOURCE_ID), Operator::EQUAL, $resource->getID()))), $this->table->getName(), $resource);
     //TODO decommentare quando AuthenticationManager è operativo
     //aggiorno lo stato della risorsa (se chi l'ha modificata è un redattore).
     //if(AuthenticationManager::isEditor($editor)) {
     //	$resource->setEditable(false);
     //	$resource->setRemovable(false);
     //	$this->updateState($resource);
     //}
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore aggiornando il dato. Riprovare.");
     }
     //salvo i tag che non esistono
     if (!is_null($resource->getTags()) && trim($resource->getTags()) != "") {
         TagManager::createTags(explode(",", $resource->getTags()));
     }
     return $resource->setModificationDate($modDate);
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:38,代码来源:ResourceDao.php

示例12: update

 function update()
 {
     require_once "query.php";
     $db = new DBManager();
     if (!$db->connect_errno()) {
         $table = Query::getDBSchema()->getTable(TABLE_VOTE);
         $rs = $db->execute($s = Query::generateSelectStm(array($table), array(), array(new WhereConstraint($table->getColumn(VOTE_AUTHOR), Operator::EQUAL, $this->getAuthor()), new WhereConstraint($table->getColumn(VOTE_POST), Operator::EQUAL, $this->getPost())), array()), $table->getName(), $this);
         //echo "<br />" . $s; //DEBUG
         $data = array();
         if ($db->num_rows() == 1) {
             $row = $db->fetch_result();
             //cerco le differenze e le salvo.
             if ($row[VOTE_VOTE] != $this->getVote()) {
                 $data[VOTE_VOTE] = $this->getVote();
             }
             break;
             //echo "<br />" . serialize($data); //DEBUG
             $rs = $db->execute($s = Query::generateUpdateStm($table, $data, array(new WhereConstraint($table->getColumn(VOTE_AUTHOR), Operator::EQUAL, $this->getAuthor()), new WhereConstraint($table->getColumn(VOTE_POST), Operator::EQUAL, $this->getPost()))), $table->getName(), $this);
             //echo "<br />" . $s; //DEBUG
             //echo "<br />" . $rs; //DEBUG
             if ($db->affected_rows() == 1) {
                 //echo "<br />" . $this; //DEBUG
                 return $this;
             } else {
                 $db->display_error("Vote::update()");
             }
         } else {
             $db->display_error("Vote::update()");
         }
     } else {
         $db->display_connect_error("Vote::update()");
     }
     return false;
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:34,代码来源:PostCommon.php


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