本文整理汇总了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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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());
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例12: insert
public function insert($pa_options = null)
{
$this->_generateSortableValue();
// populate sort field
return parent::insert($pa_options);
}
示例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);
}
}
示例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);
}
}
示例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;
}
}