本文整理汇总了PHP中fORM::objectify方法的典型用法代码示例。如果您正苦于以下问题:PHP fORM::objectify方法的具体用法?PHP fORM::objectify怎么用?PHP fORM::objectify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fORM
的用法示例。
在下文中一共展示了fORM::objectify方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
/**
* Sets a value to the record
*
* @param string $column The column to set the value to
* @param mixed $value The value to set
* @return fActiveRecord This record, to allow for method chaining
*/
protected function set($column, $value)
{
if (!array_key_exists($column, $this->values)) {
throw new fProgrammerException('The column specified, %s, does not exist', $column);
}
// We consider an empty string or a string of spaces to be equivalent to NULL
if ($value === '' || is_string($value) && trim($value) === '') {
$value = NULL;
}
$class = get_class($this);
$value = fORM::objectify($class, $column, $value);
// Float and int columns that look like numbers with commas will have the commas removed
if (is_string($value)) {
$table = fORM::tablize($class);
$schema = fORMSchema::retrieve($class);
$type = $schema->getColumnInfo($table, $column, 'type');
if (in_array($type, array('integer', 'float')) && preg_match('#^(\\d+,)+\\d+(\\.\\d+)?$#', $value)) {
$value = str_replace(',', '', $value);
}
}
self::assign($this->values, $this->old_values, $column, $value);
return $this;
}
示例2: setDateUpdated
/**
* Sets the appropriate column values to the date the object was updated
*
* @internal
*
* @param fActiveRecord $object The fActiveRecord instance
* @param array &$values The current values
* @param array &$old_values The old values
* @param array &$related_records Any records related to this record
* @param array &$cache The cache array for the record
* @return void
*/
public static function setDateUpdated($object, &$values, &$old_values, &$related_records, &$cache)
{
$class = get_class($object);
foreach (self::$date_updated_columns[$class] as $column => $enabled) {
fActiveRecord::assign($values, $old_values, $column, fORM::objectify($class, $column, date('Y-m-d H:i:s')));
// If the column has a corresponding timezone column, set that too
if (isset(self::$timestamp_columns[$class][$column])) {
fActiveRecord::assign($values, $old_values, self::$timestamp_columns[$class][$column], fTimestamp::getDefaultTimezone());
}
}
}