本文整理汇总了PHP中ActiveRecord::update方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::update方法的具体用法?PHP ActiveRecord::update怎么用?PHP ActiveRecord::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::update方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Modificar
public function Modificar()
{
$data = $this->VerPerfil();
$db = new db();
$db->connect();
$C = new ActiveRecord('fk_perfiles');
$C->fields['nombre_perfil'] = $this->nombre_perfil;
$C->fields['descripcion'] = $this->descripcion;
if ($data) {
$C->fields['id_perfil'] = $this->id_perfil;
$C->update();
} else {
$C->insert();
}
$db->close();
}
示例2: saveObject
/**
* @return bool
*/
public function saveObject()
{
if (!$this->beforeSave()) {
return false;
}
global $ilUser;
/**
* @var ilObjUser $ilUser
*/
if (!$this->setArFieldsAfterSubmit()) {
return false;
}
$modified_by_field = $this->getFields()->getModifiedByField();
if ($modified_by_field) {
$set_modified_by_function = $modified_by_field->getSetFunctionName();
$this->ar->{$set_modified_by_function}($ilUser->getId());
}
$modification_date_field = $this->getFields()->getModificationDateField();
if ($modification_date_field) {
$set_modification_date_function = $modification_date_field->getSetFunctionName();
$datetime = new ilDateTime(time(), IL_CAL_UNIX);
$this->ar->{$set_modification_date_function}($datetime);
}
if ($this->ar->getPrimaryFieldValue() != 0) {
$this->ar->update();
} else {
$created_by_field = $this->getFields()->getCreatedByField();
if ($created_by_field) {
$set_created_by_function = $created_by_field->getSetFunctionName();
$this->ar->{$set_created_by_function}($ilUser->getId());
}
$creation_date_field = $this->getFields()->getCreationDateField();
if ($creation_date_field) {
$set_creation_date_function = $creation_date_field->getSetFunctionName();
$datetime = new ilDateTime(time(), IL_CAL_UNIX);
$this->ar->{$set_creation_date_function}($datetime);
}
$this->ar->create();
}
return $this->afterSave();
}
示例3: update
public function update()
{
global $ilUser;
$this->setOwner($ilUser->getId());
$this->setUpdateDate(time());
parent::update();
}
示例4: update
public function update()
{
global $ilUser;
$this->setOwner($ilUser->getId());
$this->setUpdateDate(time());
if (!$this->hasChecks() and $this->getStatus() == self::STATUS_ACTIVE) {
ilUtil::sendInfo(ilUserDefaultsPlugin::getInstance()->txt('msg_activation_failed'));
ilUtil::sendInfo(ilUserDefaultsPlugin::getInstance()->txt('msg_activation_failed'), true);
$this->setStatus(self::STATUS_INACTIVE);
}
parent::update();
}
示例5: saveLines
private function saveLines()
{
$tableId = $this->tableId;
$total = fk_post($tableId . '_tot');
for ($i = 1; $i <= $total; $i++) {
$id_rec = fk_post($tableId . '_recId-' . $i);
$Ar = new ActiveRecord($this->table_name);
if ($id_rec > 0) {
//UPDATE
//procesar fields to save
foreach ($this->fields_to_save as $key => $value_from) {
$arr_src = array('{table-id}', '{row-id}');
$arr_repl = array($tableId . '_', '-' . $i);
$value = str_replace($arr_src, $arr_repl, $value_from);
$Ar->fields[$key] = fk_post($value);
}
$Ar->fields[$this->record_id_name] = $id_rec;
$Ar->display_queries = true;
$Ar->update();
} else {
//INSERT
//procesar fields to save
foreach ($this->fields_to_save as $key => $value_from) {
$arr_src = array('{table-id}', '{row-id}');
$arr_repl = array($tableId . '_', '-' . $i);
$value = str_replace($arr_src, $arr_repl, $value_from);
$Ar->fields[$key] = fk_post($value);
}
$Ar->insert();
}
}
}
示例6: update
/**
* Also update placeholder values and settings.
* If the certificate type did change, delete old settings/placeholder values and create new default ones from new type.
*
*/
public function update()
{
/** @var $setting srCertificateDefinitionSetting */
/** @var $pl srCertificatePlaceholderValue */
if ($this->type_changed) {
$this->signature_id = 0;
// Reset signature
}
parent::update();
// If the type did change, we destroy all settings + placeholder values from the old type and create new ones
if ($this->type_changed) {
foreach ($this->getSettings() as $setting) {
$setting->delete();
}
foreach ($this->getCustomSettings() as $custom_setting) {
$custom_setting->delete();
}
foreach ($this->getPlaceholderValues() as $pl) {
$pl->delete();
}
$this->createSettings();
$this->createPlaceholderValues();
} else {
foreach ($this->getSettings() as $setting) {
$setting->update();
}
foreach ($this->getCustomSettings() as $setting) {
$setting->update();
}
foreach ($this->getPlaceholderValues() as $pl) {
$pl->update();
}
}
}
示例7: generarConsecutivo
public static function generarConsecutivo($codigo, $increment = true)
{
// GenerarConsecutivo
$Configsys = new ActiveRecord('config_sys');
$tot_contador = $Configsys->find_where('config_code = "' . $codigo . '" ');
if ($tot_contador == 0) {
// No existe
$numero_consecutivo = 1;
if ($increment == true) {
$Configsys->fields['config_code'] = $codigo;
$Configsys->fields['config_value'] = $numero_consecutivo;
$Configsys->insert();
}
} else {
// Si existe
$numero_consecutivo = $Configsys->fields['config_value'] + 1;
// INCREMENTA
if ($increment == true) {
$Configsys->fields['config_value'] = $numero_consecutivo;
$numero_consecutivo = $Configsys->fields['config_value'];
$Configsys->update();
}
}
return $numero_consecutivo;
}
示例8: ModificarAdmin
public function ModificarAdmin()
{
$data = $this->VerUsuario();
$db = new db();
$db->connect();
$C = new ActiveRecord('usuarios');
$C->fields['usuario'] = $this->usuario;
$C->fields['nombre'] = $this->nombre;
$C->fields['apellidos'] = $this->apellidos;
$C->fields['id_tipo'] = $this->id_tipo;
$un = strtoupper($this->nombre[0] . $this->apellidos[0]);
$x = '';
do {
$username = $un . $x;
$sql = 'SELECT * FROM usuarios WHERE usuario = "' . $username . '"';
if ($data) {
$sql .= ' AND id_usuario != ' . $this->id_usuario;
}
$db->query($sql);
$f = $db->next();
$x++;
} while ($f != 0);
$C->fields['usuario'] = $username;
if ($this->password != '') {
$C->fields['password'] = md5($this->password);
}
$C->fields['email'] = $this->email;
if ($this->id_perfil != 0) {
$C->fields['id_perfil'] = $this->id_perfil;
}
if ($data) {
$C->fields['id_usuario'] = $this->id_usuario;
$C->update();
} else {
$C->fields['fecha_reg'] = $this->fecha_reg;
$C->insert();
}
$db->close();
}
示例9: update
protected function update()
{
$this->executePlugins($this, 'update');
$res = parent::update();
$this->executePlugins($this, 'save');
return $res;
}
示例10: update
public function update()
{
parent::update();
if ($this->hasStatusChanged()) {
// Status has changed
$this->event_handler->raise('Certificate/srCertificate', 'changeStatus', array('object' => $this, 'old_status' => $this->old_status, 'new_status' => $this->status));
}
$this->event_handler->raise('Certificate/srCertificate', 'update', array('object' => $this));
$this->old_status = null;
}
示例11: send_password
public function send_password()
{
Context::get('db')->start_transaction();
// set new password
$this->password = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'), 0, 8);
$this->create_new_salt();
$this->encrypt_password($this->password, $this->salt);
parent::update();
// send email
text_mail($this->email, "임시 비밀번호 발급 안내", "임시 비밀번호는 \"{$this->password}\" 입니다.");
Context::get('db')->commit();
}
示例12: update
public function update()
{
$this->mapToActiveRecord();
parent::update();
}