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


PHP Dao::save方法代码示例

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


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

示例1: save

 function save($resource)
 {
     parent::save($resource, self::OBJECT_CLASS);
     $this->logger->debug("ResourceDao", "salvo risorsa " . $resource->getPath());
     $data = array(DB::RESOURCE_OWNER => $resource->getOwnerId(), DB::RESOURCE_PATH => $resource->getPath(), DB::RESOURCE_TYPE => $resource->getType());
     if (!is_null($resource->getDescription())) {
         $data[DB::RESOURCE_DESCRIPTION] = $resource->getDescription();
     }
     if (!is_null($resource->getTags())) {
         $data[DB::RESOURCE_TAGS] = $resource->getTags();
     }
     $data[DB::POST_CREATION_DATE] = date("Y-m-d G:i:s", $_SERVER["REQUEST_TIME"]);
     $this->db->execute($s = Query::generateInsertStm($this->table, $data), $this->table->getName(), $this);
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore salvando l'oggetto. Riprovare.");
     }
     $r = $this->quickLoad($this->db->last_inserted_id());
     //DEBUG
     //var_dump($this->db->last_inserted_id());
     //inserisco i tag nuovi
     if (!is_null($resource->getTags()) && trim($resource->getTags()) != "") {
         TagManager::createTags(explode(",", $resource->getTags()));
     }
     //salvo lo stato della risorsa perché l'utente potrebbe aver già modificato il suo "colore".
     $this->updateState($r);
     return $r;
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:27,代码来源:ResourceDao.php

示例2: save

 function save($contact)
 {
     parent::save($contact, self::OBJECT_CLASS);
     $data = array(DB::CONTACT_CONTACT => $contact->getContact(), DB::CONTACT_NAME => $contact->getName(), DB::CONTACT_USER => $contact->getUserId());
     $this->db->execute($s = Query::generateInsertStm($this->table, $data), $this->table->getName(), $contact);
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore salvando l'oggetto. Riprovare.");
     }
     $c = $this->quickLoad($this->db->last_inserted_id());
     return $c;
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:11,代码来源:ContactDao.php

示例3: save

 function save($comm)
 {
     parent::save($comm, self::OBJECT_CLASS);
     $data = array(DB::COMMENT_COMMENT => $comm->getComment(), DB::COMMENT_POST => $comm->getPost(), DB::COMMENT_AUTHOR => $comm->getAuthor());
     $rs = $this->db->execute($s = Query::generateInsertStm($this->table, $data), $this->table->getName(), $comm);
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Errore durante l'inserimento dell'oggetto.");
     }
     //carico il post inserito.
     $c = $this->quickLoad(intval($this->db->last_inserted_id()));
     return $c;
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:12,代码来源:CommentDao.php

示例4: save

 function save($report)
 {
     parent::save($report, self::OBJECT_CLASS);
     $data = array(DB::REPORT_TEXT => $report->getReport(), DB::REPORT_OBJECT_ID => $report->getObject()->getID(), DB::REPORT_OBJECT_CLASS => get_class($report->getObject()), DB::REPORT_USER => $report->getAuthor());
     $rs = $this->db->execute($s = Query::generateInsertStm($this->table, $data), $this->table->getName(), $report);
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore. Riprovare.");
     }
     //aggiorno lo stato dell'oggetto che è stato segnalato.
     $this->updateObjectState($report->getObject());
     return $this->db->quickLoad($report->getID());
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:12,代码来源:ReportDao.php

示例5: save

 function save($post, $author, $vote)
 {
     parent::save($post, "Post");
     parent::save($author, "User");
     settype($vote, "boolean");
     //elimino il vecchio voto
     $this->db->execute(Query::generateDeleteStm($this->table, array(new WhereConstraint($this->table->getColumn(DB::VOTE_AUTHOR), Operator::EQUAL, intval($author->getID()), new WhereConstraint($this->table->getColumn(DB::VOTE_POST), Operator::EQUAL, intval($post->getID()))))), $this->table->getName(), array($author->getID(), $post->getID()));
     //non controllo se è stato cancellato perché può non esserci
     $data = array(DB::VOTE_VOTE => $vote ? 1 : 0, DB::VOTE_POST => intval($post->getID()), DB::VOTE_AUTHOR => intval($author->getID()));
     $this->db->execute($s = Query::generateInsertStm($this->table, $data), $this->table->getName(), $data);
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore salvando l'oggetto. Riprovare.");
     }
     //carico il voto inserito.
     $this->db->execute($s = Query::generateSelectStm(array($this->table), array(), array(new WhereConstraint($this->table->getColumn(DB::VOTE_AUTHOR), Operator::EQUAL, intval($author->getID()), new WhereConstraint($this->table->getColumn(DB::VOTE_POST), Operator::EQUAL, intval($post->getID())))), array()), $this->table->getName(), $data);
     if ($this->db->num_rows() != 1) {
         throw new Exception("Si è verificato un errore salvando l'oggetto. Riprovare.");
     }
     return true;
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:20,代码来源:VoteDao.php

示例6: save

 function save($user)
 {
     parent::save($user, self::OBJECT_CLASS);
     $data = array();
     if (!is_null($user->getAvatar())) {
         $data[DB::USER_AVATAR] = $user->getAvatar();
     }
     if (!is_null($user->getBirthday())) {
         $data[DB::USER_BIRTHDAY] = date("Y/m/d", $user->getBirthday());
     }
     if (!is_null($user->getBirthplace())) {
         $data[DB::USER_BIRTHPLACE] = $user->getBirthplace();
     }
     if (!is_null($user->getEMail())) {
         $data[DB::USER_E_MAIL] = $user->getEMail();
     }
     if (!is_null($user->getGender())) {
         $data[DB::USER_GENDER] = $user->getGender();
     }
     if (!is_null($user->getHobbies())) {
         $data[DB::USER_HOBBIES] = $user->getHobbies();
     }
     if (!is_null($user->getJob())) {
         $data[DB::USER_JOB] = $user->getJob();
     }
     if (!is_null($user->getLivingPlace())) {
         $data[DB::USER_LIVINGPLACE] = $user->getLivingPlace();
     }
     if (!is_null($user->getName())) {
         $data[DB::USER_NAME] = $user->getName();
     }
     if (!is_null($user->getNickname())) {
         $data[DB::USER_NICKNAME] = $user->getNickname();
     }
     if (!is_null($user->getPassword())) {
         $data[DB::USER_PASSWORD] = $user->getPassword();
     }
     if (!is_null($user->getRole())) {
         $data[DB::USER_ROLE] = $user->getRole();
     }
     if (!is_null($user->getSurname())) {
         $data[DB::USER_SURNAME] = $user->getSurname();
     }
     if (!is_null($user->getVisible())) {
         $data[DB::USER_VISIBLE] = $user->getVisible() ? 1 : 0;
     }
     $data[DB::USER_CREATION_DATE] = date("Y-m-d G:i:s", $_SERVER["REQUEST_TIME"]);
     $this->db->execute($s = Query::generateInsertStm($this->table, $data), $this->table->getName(), $user);
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore salvando l'oggetto. Riprovare.");
     }
     $u = $this->load(intval($this->db->last_inserted_id()));
     $this->updateState($u);
     return $u;
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:55,代码来源:UserDao.php

示例7: save

 function save($post)
 {
     parent::save($post, self::OBJECT_CLASS);
     $data = array(DB::POST_TYPE => $post->getType());
     if (!is_null($post->getTitle())) {
         $data[DB::POST_TITLE] = $post->getTitle();
     }
     if (!is_null($post->getSubtitle())) {
         $data[DB::POST_SUBTITLE] = $post->getSubtitle();
     }
     if (!is_null($post->getHeadline())) {
         $data[DB::POST_HEADLINE] = $post->getHeadline();
     }
     if (!is_null($post->getTags())) {
         $data[DB::POST_TAGS] = $post->getTags();
     }
     if (!is_null($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 (is_null($post->getCategories()) || count($new_cat) == 0) {
             $new_cat[] = self::DEFAULT_CATEGORY;
         }
         $post->setCategories(Filter::arrayToText($new_cat));
         $data[DB::POST_CATEGORIES] = $post->getCategories();
     }
     if (!is_null($post->getContent())) {
         if ($post->getType() == Post::NEWS || $post->getType() == Post::VIDEOREP) {
             $data[DB::POST_CONTENT] = $post->getContent();
         } else {
             $data[DB::POST_CONTENT] = serialize($post->getContent());
         }
     }
     if (!is_null($post->isVisible())) {
         $data[DB::POST_VISIBLE] = $post->isVisible() ? 1 : 0;
     }
     if (!is_null($post->getAuthor())) {
         $data[DB::POST_AUTHOR] = $post->getAuthor();
     }
     if (!is_null($post->getPlace())) {
         $data[DB::POST_PLACE] = $post->getPlace();
     }
     $post->setCreationDate($_SERVER["REQUEST_TIME"]);
     if (is_null($post->getPermalink())) {
     }
     $post->setPermalink($this->generatePermalink($post));
     $data[DB::POST_PERMALINK] = $post->getPermalink();
     $rand = "";
     $count = 0;
     while ($this->permalinkExists($post->getPermalink() . $rand)) {
         if ($count >= 1000) {
             throw new Exception("Attenzione! Hai troppi atricol che si chiamano in questo modo. Prova a cambiare titolo.");
         }
         //finché esiste già un permalink del genere, ne genero uno random.
         $rand = "(" . rand(65535, $_SERVER["REQUEST_TIME"]) . ")";
         $data[DB::POST_PERMALINK] = $post->getPermalink() . $rand;
         $count++;
     }
     $data[DB::POST_CREATION_DATE] = date("Y-m-d G:i:s", $post->getCreationDate());
     $rs = $this->db->execute($s = Query::generateInsertStm($this->table, $data), $this->table->getName(), $this);
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore salvando l'oggetto. Riprovare.");
     }
     //carico il post inserito.
     $p = $this->load(intval($this->db->last_inserted_id()));
     //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]));
     }
     //salvo lo stato del post perché l'utente potrebbe aver già modificato il suo "colore".
     $this->updateState($p);
     return $p;
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:74,代码来源:PostDao.php

示例8: activate

 /**
  * Activate an entity instance
  *
  * @param BaseEntityAbstract $entity The entity that we are trying to activate
  *
  * @return int The number rows affected
  */
 public function activate(BaseEntityAbstract $entity)
 {
     $entity->setActive(true);
     $entity = Dao::save($entity);
     $this->_affectedRows = 1;
     $this->_lastId = -1;
     $this->resetQuery();
     return $this->_affectedRows;
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:16,代码来源:EntityDao.php

示例9: save

 function save($cat)
 {
     parent::save($cat, self::OBJECT_CLASS);
     $data = array();
     if (!is_null($cat->getName())) {
         $data[DB::CATEGORY_NAME] = $cat->getName();
     }
     if (!is_null($cat->getAuthorId())) {
         $data[DB::CATEGORY_AUTHOR] = $cat->getAuthorId();
     }
     if (!is_null($cat->getCreationDate())) {
         $data[DB::CATEGORY_CREATION_DATE] = date("Y-m-d G:i:s", $cat->getCreationDate());
     }
     $this->db->execute(Query::generateInsertStm($this->table, $data));
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore salvando l'oggetto. Riprovare.");
     }
     if (!is_null($cat->getParentName())) {
         $this->db->execute(Query::generateInsertStm($this->table_sc, array(DB::SUB_CATEGORY_CATEGORY => $cat->getName(), DB::SUB_CATEGORY_PARENT => $cat->getParentName())));
         if ($this->db->affected_rows() != 1) {
             throw new Exception("Si è verificato un errore salvando l'oggetto. Riprovare.");
         }
     }
     return $cat;
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:25,代码来源:CategoryDao.php

示例10: subscribePost

 function subscribePost($post, $contest)
 {
     parent::save($contest, self::OBJECT_CLASS);
     parent::save($post, "Post");
     if ($post->getType() != $contest->getSubscriberType()) {
         throw new Exception("Non puoi iscrivere questo post nel contest selezionato.");
     }
     if (time() > $contest->getEnd()) {
         throw new Exception("Non puoi iscrivere questo post perché scaduto il termine di iscrizione.");
     }
     $this->db->execute($s = Query::generateInsertStm($this->table_cs, array(DB::CONTEST_SUBSCRIBER_POST => $post->getID(), DB::CONTEST_SUBSCRIBER_CONTEST => $contest->getID())), $table->getName(), $contest);
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Errore iscrivendo il post nel contest. Il post potrebbe essere già iscritto.");
     }
     //$this->loadSubscribers($contest); //FIXME vale la pena ricaricare il contest?
     return $contest;
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:17,代码来源:ContestDao.php


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