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


PHP BaseModel::insert方法代码示例

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


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

示例1: insert

 public function insert($data)
 {
     // Cria novo album de fotos
     if ($this->albumModel) {
         $data->album = $this->albumModel->insert($data);
     }
     $this->mapping->fields['name'] = 'accountFirstName';
     $this->mapping->fields['surname'] = 'accountLastName';
     $this->mapping->fields['sex'] = 'accountSex';
     $this->mapping->fields['email'] = 'accountEmail';
     $this->mapping->fields['password'] = 'accountPassword';
     $this->mapping->fields['news'] = 'accountNews';
     $this->mapping->fields['album'] = 'albumID';
     // Tratamento adicional de dados
     $data->password = md5($data->password);
     $data->news = (int) $data->news;
     try {
         $this->dbh->beginTransaction();
         $newID = parent::insert($data);
         $this->dbh->commit();
         return $newID;
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(Text::read('message.model.error.insert'), $exception);
     }
 }
开发者ID:sohflp,项目名称:Hooked,代码行数:26,代码来源:class.AccountModel.php

示例2: insert

 public function insert($pa_options = null)
 {
     $this->_generateSortableValue();
     // populate sort field
     // invalidate get() prefetch cache
     SearchResult::clearResultCacheForTable($this->tableName());
     return parent::insert($pa_options);
 }
开发者ID:kai-iak,项目名称:providence,代码行数:8,代码来源:BaseLabel.php

示例3: insert

 public function insert($data)
 {
     $this->mapping->table = 'users_roles';
     $this->mapping->fields['user'] = 'userID';
     $this->mapping->fields['role'] = 'roleID';
     try {
         parent::insert($data);
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(get_called_class() . "::" . __FUNCTION__, Text::read('message.model.error.insert'), $exception);
     }
 }
开发者ID:sohflp,项目名称:Hooked,代码行数:12,代码来源:class.RoleModel.php

示例4: insert

 public function insert($data)
 {
     $this->mapping->fields['id'] = 'typeID';
     $this->mapping->fields['feature'] = 'featureTitle';
     try {
         $this->dbh->beginTransaction();
         $newID = parent::insert($data);
         $this->dbh->commit();
         return $newID;
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(Text::read('message.model.error.insert'), $exception);
     }
 }
开发者ID:sohflp,项目名称:Hooked,代码行数:14,代码来源:class.FeatureModel.php

示例5: insert

 public function insert($data)
 {
     $this->mapping->fields['text'] = 'messageText';
     $this->mapping->fields['product'] = 'productID';
     $this->mapping->fields['account'] = 'accountID';
     $this->mapping->fields['parent'] = 'messageParentID';
     try {
         $this->dbh->beginTransaction();
         $newID = parent::insert($data);
         $this->dbh->commit();
         return $newID;
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(Text::read('message.model.error.insert'), $exception);
     }
 }
开发者ID:sohflp,项目名称:Hooked,代码行数:16,代码来源:class.MessageModel.php

示例6: insert

 public function insert($data)
 {
     $this->mapping->fields['title'] = 'faqTitle';
     $this->mapping->fields['text'] = 'faqText';
     $this->mapping->fields['user'] = 'createdBy';
     // Tratamento adicional de dados
     $data->user = $_SESSION['admLogin']->getUserID();
     try {
         $this->dbh->beginTransaction();
         $newID = parent::insert($data);
         $this->dbh->commit();
         return $newID;
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(get_called_class() . "::" . __FUNCTION__, Text::read('message.model.error.insert'), $exception);
     }
 }
开发者ID:sohflp,项目名称:Hooked,代码行数:17,代码来源:class.FAQModel.php

示例7: insert

 public function insert($data)
 {
     $this->mapping->fields['title'] = 'inboxTitle';
     $this->mapping->fields['text'] = 'inboxText';
     $this->mapping->fields['type'] = 'inboxType';
     $this->mapping->fields['reference'] = 'inboxReference';
     $this->mapping->fields['account'] = 'accountID';
     try {
         $this->dbh->beginTransaction();
         $newID = parent::insert($data);
         $this->dbh->commit();
         return $newID;
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(Text::read('message.model.error.insert'), $exception);
     }
     var_dump($this->getTechnicalMessage());
 }
开发者ID:sohflp,项目名称:Hooked,代码行数:18,代码来源:class.InboxModel.php

示例8: insert

 public function insert($data)
 {
     // Cria novo album de fotos
     $data->album = $this->albumModel->insert($data);
     $this->mapping->fields['title'] = 'brandTitle';
     $this->mapping->fields['album'] = 'albumID';
     $this->mapping->fields['user'] = 'createdBy';
     // Tratamento adicional de dados
     $data->user = $_SESSION['admLogin']->getUserID();
     try {
         $this->dbh->beginTransaction();
         $newID = parent::insert($data);
         $this->dbh->commit();
         return $newID;
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(Text::read('message.model.error.insert'), $exception);
     }
 }
开发者ID:sohflp,项目名称:Hooked,代码行数:19,代码来源:class.BrandModel.php

示例9: insert

 /**
  * Creates new user record. You must set all required user fields before calling this method. If errors occur you can use the standard Table class error handling methods to figure out what went wrong.
  *
  * Required fields are user_name, password, fname and lname.
  *
  * @access public 
  * @return bool Returns true if no error, false if error occurred
  */
 public function insert($pa_options = null)
 {
     if (!caCheckEmailAddress($this->get('email'))) {
         $this->postError(922, _t("Invalid email address"), 'ca_users->insert()');
         return false;
     }
     # Confirmation key is an md5 hash than can be used as a confirmation token. The idea
     # is that you create a new user record with the 'active' field set to false. You then
     # send the confirmation key to the new user (usually via e-mail) and ask them to respond
     # with the key. If they do, you know that the e-mail address is valid.
     if (function_exists('mcrypt_create_iv')) {
         $vs_confirmation_key = md5(mcrypt_create_iv(24, MCRYPT_DEV_URANDOM));
     } else {
         $vs_confirmation_key = md5(uniqid(mt_rand(), true));
     }
     $this->set("confirmation_key", $vs_confirmation_key);
     try {
         $vs_backend_password = AuthenticationManager::createUserAndGetPassword($this->get('user_name'), $this->get('password'));
         $this->set('password', $vs_backend_password);
     } catch (AuthClassFeatureException $e) {
         // auth class does not implement creating users at all
         $this->postError(925, _t("Current authentication adapter does not support creating new users."), 'ca_users->insert()');
         return false;
     } catch (Exception $e) {
         // some other error in auth class, e.g. user couldn't be found in directory
         $this->postError(925, $e->getMessage(), 'ca_users->insert()');
         $this->opo_log->log(array('CODE' => 'SYS', 'SOURCE' => 'ca_users/insert', 'MESSAGE' => _t('Authentication adapter could not create user. Message was: %1', $e->getMessage())));
         return false;
     }
     # set user vars (the set() method automatically serializes the vars array)
     $this->set("vars", $this->opa_user_vars);
     $this->set("volatile_vars", $this->opa_volatile_user_vars);
     return parent::insert($pa_options);
 }
开发者ID:kai-iak,项目名称:providence,代码行数:42,代码来源:ca_users.php

示例10: insert

 public function insert($data)
 {
     $this->mapping->fields['login'] = 'userLogin';
     $this->mapping->fields['name'] = 'userName';
     $this->mapping->fields['email'] = 'userEmail';
     $this->mapping->fields['password'] = 'userPassword';
     $this->mapping->fields['blocked'] = 'userBlocked';
     $this->mapping->fields['user'] = 'createdBy';
     // Tratamento adicional de dados
     $data->password = md5($data->password);
     $data->blocked = $data->blocked ? 1 : 0;
     $data->user = $_SESSION['admLogin']->getUserID();
     try {
         $this->dbh->beginTransaction();
         $newID = parent::insert($data);
         if (is_array($data->roles)) {
             // Adiciona funções do usuário
             $roleData = new stdclass();
             $roleData->user = $newID;
             foreach ($data->roles as $role) {
                 $roleData->role = $role;
                 $this->roleModel->insert($roleData);
             }
         }
         $this->dbh->commit();
         return $newID;
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(get_called_class() . "::" . __FUNCTION__, Text::read('message.model.error.insert'), $exception);
     }
 }
开发者ID:sohflp,项目名称:Hooked,代码行数:31,代码来源:class.UserModel.php

示例11: insert

 public function insert(array $data)
 {
     if ($this->config['useAcl']) {
         // check rights
         if (!$this->user->isAllowed(Acl::RESOURCE_USER, Acl::PRIVILEGE_ADD)) {
             throw new OperationNotAllowedException();
         }
     }
     $data['token'] = md5($data['email'] . $data['username']);
     $data['registered'] = dibi::datetime();
     if (isset($data['roles'])) {
         $roles = $data['roles'];
         unset($data['roles']);
     }
     if (isset($data['client_logo'])) {
         $clientLogo = $data['client_logo'];
         unset($data['client_logo']);
     }
     // create user and update his password - needed because getHasherParamsFromUserData() requires $userId
     try {
         dibi::begin();
         // save random password temporarily
         $realPassword = $data['password'];
         $data['password'] = Basic::randomizer(40);
         $userId = parent::insert($data);
         $data['password'] = $realPassword;
         $this->update($userId, $data);
         dibi::commit();
     } catch (DibiDriverException $e) {
         dibi::rollback();
         throw $e;
     }
     if (isset($roles)) {
         $this->getRolesModel()->updateUserRoles($userId, (array) $roles);
     }
     if (!empty($clientLogo)) {
         $this->saveClientLogo($userId, $clientLogo);
     }
     return $userId;
 }
开发者ID:radypala,项目名称:maga-website,代码行数:40,代码来源:UsersModel.php

示例12: insert

 public function insert($pa_options = null)
 {
     $this->_generateSortableValue();
     // populate sort field
     return parent::insert($pa_options);
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:6,代码来源:BaseLabel.php

示例13: insert

 public function insert($data)
 {
     // Cria novo album de fotos
     $data->album = $this->albumModel->insert($data);
     // Converte preço para formato do Banco
     $data->price = str_replace(',', '.', $data->price);
     $data->discount = str_replace(',', '.', $data->discount);
     $this->mapping->fields['name'] = 'productName';
     $this->mapping->fields['text'] = 'productDescription';
     $this->mapping->fields['type'] = 'typeID';
     $this->mapping->fields['subtype'] = 'subTypeID';
     $this->mapping->fields['brand'] = 'brandID';
     $this->mapping->fields['price'] = 'productPrice';
     $this->mapping->fields['discount'] = 'productDiscount';
     $this->mapping->fields['account'] = 'accountID';
     $this->mapping->fields['album'] = 'albumID';
     try {
         $this->dbh->beginTransaction();
         $newID = parent::insert($data);
         $this->dbh->commit();
         return $newID;
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(Text::read('message.model.error.insert'), $exception);
     }
 }
开发者ID:sohflp,项目名称:Hooked,代码行数:26,代码来源:class.ProductModel.php

示例14: insert

 public function insert($data)
 {
     $this->mapping->fields['product'] = 'productID';
     $this->mapping->fields['buyer'] = 'buyerID';
     $this->mapping->fields['vendor'] = 'vendorID';
     $this->mapping->fields['shipping'] = 'orderShippingType';
     if ($this->addressModel) {
         $this->mapping->fields = array_merge($this->mapping->fields, $this->addressModel->addressMapping());
     }
     try {
         $this->dbh->beginTransaction();
         $newID = parent::insert($data);
         $this->dbh->commit();
         return $newID;
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(Text::read('message.model.error.insert'), $exception);
     }
 }
开发者ID:sohflp,项目名称:Hooked,代码行数:19,代码来源:class.OrderModel.php

示例15: insert

 /**
  *
  */
 public function insert($pa_options = null)
 {
     $t_trans = new ca_commerce_transactions($this->get('transaction_id'));
     if ($t_trans->getPrimaryKey()) {
         if ($vn_set_id = $t_trans->get('set_id')) {
             $t_set = new ca_sets($vn_set_id);
             if ($t_set->getPrimaryKey()) {
                 $va_row_ids = $t_set->getItemRowIDs();
                 $this->set('set_snapshot', array('table_num' => $t_set->get('table_num'), 'set_id' => $vn_set_id, 'datetime' => time(), 'items' => $va_row_ids));
             }
         }
         return parent::insert($pa_options);
     } else {
         $this->postError(1500, _t('Transaction does not exist'), 'ca_commerce_communications->insert()');
         return false;
     }
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:20,代码来源:ca_commerce_communications.php


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