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


PHP waModel::insert方法代码示例

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


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

示例1: save

 /**
  * Save this record to database: insert or update depending on whether record exists in DB.
  * Silently ignores all keys that have no corresponding fields in database table.
  *
  * @return mixed this record id
  * @throws waException when values fail validation
  */
 public function save()
 {
     $this->beforeSave();
     $values = array_intersect_key($this->removeStubs()->rec_data, $this->m->getMetadata());
     if ($this->id === null) {
         $this->id = $this->m->insert($values);
         $this[$this->m->getTableId()] = $this->id;
     } else {
         $this->m->updateById($this->id, $values);
     }
     $this->afterSave();
     $this->merge();
     return $this->id;
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:21,代码来源:waDbRecord.class.php

示例2: insert

 public function insert($data, $type = 0)
 {
     if (!isset($data['application_id'])) {
         $data['application_id'] = waSystem::getInstance()->getApp();
     }
     if (!isset($data['create_datetime'])) {
         $data['create_datetime'] = date('Y-m-d H:i:s');
     }
     return parent::insert($data);
 }
开发者ID:nowaym,项目名称:webasyst-framework,代码行数:10,代码来源:waTransaction.model.php

示例3: insert

 public function insert($data, $type = 0)
 {
     if (!isset($data['create_contact_id'])) {
         $data['create_contact_id'] = waSystem::getInstance()->getUser()->getId();
     }
     if (!isset($data['create_app_id'])) {
         $data['create_app_id'] = waSystem::getInstance()->getApp();
     }
     if (!isset($data['create_datetime'])) {
         $data['create_datetime'] = date("Y-m-d H:i:s");
     }
     return parent::insert($data, $type = 0);
 }
开发者ID:Favorskij,项目名称:webasyst-framework,代码行数:13,代码来源:waContact.model.php

示例4: save

 /**
  * Save this record to database: insert or update depending on whether record exists in DB.
  * Silently ignores all keys that have no corresponding fields in database table.
  *
  * @return mixed this record id
  * @throws waException when values fail validation
  */
 public function save()
 {
     $this->beforeSave();
     $values = array_intersect_key($this->removeStubs()->rec_data, $this->m->getMetadata());
     $do_insert = true;
     $id = $this->getId();
     // Force saving with given id, if specified during construction
     $id || ($id = $this->persistent->ifset($this->m->getTableId()));
     // Update if record exists
     if ($id && $this->exists()) {
         if (!$values) {
             $do_insert = false;
         } else {
             $result = $this->m->updateById($this->id, $values, null, true);
             if ($result->affectedRows()) {
                 $do_insert = false;
                 if (!empty($values[$this->m->getTableId()])) {
                     $this->id = $values[$this->m->getTableId()];
                 }
             } else {
                 // Make sure the record exists
                 if ($row = $this->m->getById($this->id)) {
                     $do_insert = false;
                     $this->persistent->setAll($row);
                 } else {
                     $this->clearPersistent();
                 }
             }
         }
     } else {
         if ($id && empty($values[$this->m->getTableId()])) {
             // id was given to constructor, but no such record exists
             $values[$this->m->getTableId()] = $id;
         }
     }
     // No row in database yet: insert
     if ($do_insert) {
         unset($this->persistent[$this->m->getTableId()]);
         $this->id = $this->m->insert($values);
         $this[$this->m->getTableId()] = $this->id;
     }
     $this->afterSave();
     $this->merge();
     return $this->id;
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:52,代码来源:waDbRecord.class.php

示例5: insert

 public function insert($data, $type = 0)
 {
     if (!isset($data['sort'])) {
         $sql = "SELECT MAX(`sort`) `sort`, COUNT(1) `cnt` FROM {$this->table}";
         $where = array();
         if (is_array($this->id)) {
             $fields = $this->remapId($data);
             foreach ($fields as $field => $value) {
                 if ($value !== null) {
                     $where[] = $this->getWhereByField($field, $value);
                 }
             }
         }
         if ($this->context && isset($data[$this->context])) {
             $where[] = $this->getWhereByField($this->context, $data[$this->context]);
         }
         if ($where) {
             $sql .= ' WHERE (' . implode(') AND (', $where) . ')';
         }
         $sort = $this->query($sql)->fetchAssoc();
         if ($sort['cnt']) {
             ++$sort['sort'];
         }
         $data['sort'] = $sort['sort'];
     }
     return parent::insert($data, $type);
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:27,代码来源:shopSortable.model.php

示例6: insert

 public function insert($data, $type = 0)
 {
     $data['url'] = $this->genUniqueUrl(empty($data['url']) ? $data['name'] : $data['url']);
     return parent::insert($data, $type);
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:5,代码来源:blogCategory.model.php

示例7: insert

 public function insert($data, $type = 0)
 {
     $data['datetime'] = date('Y-m-d H:i:s');
     $data['description'] = self::$description;
     $data['type'] = self::$transaction_type;
     if (self::$params) {
         if (isset(self::$params['order_id'])) {
             $data['order_id'] = self::$params['order_id'];
         }
     }
     parent::insert($data, $type);
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:12,代码来源:shopProductStocksLog.model.php

示例8: insert

 public function insert($data, $type = 0)
 {
     if (!isset($data['create_datetime'])) {
         $data['create_datetime'] = date('Y-m-d H:i:s');
     }
     return parent::insert($data, $type);
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:7,代码来源:shopOrder.model.php


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