本文整理汇总了PHP中ActiveRecord::create方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::create方法的具体用法?PHP ActiveRecord::create怎么用?PHP ActiveRecord::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::create方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function test_should_not_insert_null_string_on_empty_binary_fields()
{
$this->installAndIncludeModels(array('Hybrid' => 'id,data binary'));
$EmptyFile =& $this->Hybrid->create(array());
$EmptyFile->reload();
$this->assertNull($EmptyFile->get('data'));
}
示例2: create
public function create()
{
parent::create();
$this->type = srCertificateType::find($this->getTypeId());
$this->createSettings();
$this->createPlaceholderValues();
}
示例3:
function test_handle_null_date_as_null()
{
$this->installAndIncludeModels(array('Hybrid' => 'id,name,born date'));
$Hans =& $this->Hybrid->create(array('name' => 'Hans', 'born' => null));
$Hans->reload();
$this->assertNull($Hans->born);
}
示例4: create
public static function create($values = array(), $save = false)
{
try {
$Mapping = parent::create($values, $save);
} catch (\DuplicateKeyException $e) {
$Mapping = static::getByWhere(array('ContextClass' => $values['Context'] ? $values['Context']->getRootClass() : $values['ContextClass'], 'Connector' => $values['Connector'], 'ExternalKey' => $values['ExternalKey'], 'ExternalIdentifier' => $values['ExternalIdentifier']));
$Mapping->ContextID = $values['Context'] ? $values['Context']->ID : $values['ContextID'];
if ($save) {
$Mapping->save();
}
}
return $Mapping;
}
示例5: 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();
}
示例6: create
public function create()
{
global $ilUser;
$this->setOwner($ilUser->getId());
$this->setUpdateDate(time());
$this->setCreateDate(time());
parent::create();
}
示例7: create
public function create()
{
global $ilUser;
$this->setOwner($ilUser->getId());
$this->setUpdateDate(time());
$this->setCreateDate(time());
if (!$this->hasChecks()) {
$this->setStatus(self::STATUS_INACTIVE);
}
parent::create();
}
示例8: setUp
public function setUp()
{
$this->installAndIncludeModels(array('Picture', 'Thumbnail'));
$Picture = $this->Picture->create(array('title' => 'This is not a picture'));
$Picture->main_thumbnail->create(array('caption' => 'It cant have a thumbnail'));
}
示例9: create
public function create()
{
parent::create();
$this->createDefaultSettings();
}
示例10: create
/**
* Create certificate
* Before calling parent::create(), the valid_from and valid_to are are calculated based on the chosen validity in the definition
* If there exists already a certificate for the given definition and user, the version is increased
*
* @throws Exception
*/
public function create()
{
if (is_null($this->getDefinition()) || !$this->getUserId()) {
throw new Exception("srCertificate::create() must have valid Definition and User-ID");
}
// Set validity dates
$valid_from = date("Y-m-d");
$valid_to = $this->calculateValidTo();
$this->setValidFrom($valid_from);
$this->setValidTo($valid_to);
// Check if we need to increase the version if a certificate for same user & definition already exists
/** @var srCertificate $cert_last_version */
$certs = srCertificate::where(array('definition_id' => $this->getDefinitionId(), 'user_id' => $this->getUserId()))->orderBy('file_version', 'DESC');
$cert_last_version = $certs->first();
if (!is_null($cert_last_version)) {
$this->setFileVersion((int) $cert_last_version->getFileVersion() + 1);
}
// Remove active flag from other versions of this certificate
/** @var srCertificate $cert */
foreach ($certs->get() as $cert) {
$cert->setActive(false);
$cert->save();
}
// Set active flag
$this->setActive(true);
// Set the filename for certificate
$this->filename = $this->createFilename();
$this->created_at = date('Y-m-d H:i:s');
parent::create();
$this->event_handler->raise('Certificate/srCertificate', 'create', array('object' => $this));
}
示例11: create
public function create()
{
$this->mapToActiveRecord();
parent::create();
}