Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • CTimestampBehavior
  • Overview
  • Package
  • Class
  • Tree

Class CTimestampBehavior

CTimestampBehavior will automatically fill date and time related attributes.

CTimestampBehavior will automatically fill date and time related attributes when the active record is created and/or updated. You may specify an active record model to use this behavior like so:

public function behaviors(){
        return array(
                'CTimestampBehavior' => array(
                        'class' => 'zii.behaviors.CTimestampBehavior',
                        'createAttribute' => 'create_time_attribute',
                        'updateAttribute' => 'update_time_attribute',
                )
        );
}

The CTimestampBehavior::$createAttribute and CTimestampBehavior::$updateAttribute options actually default to 'create_time' and 'update_time' respectively, so it is not required that you configure them. If you do not wish CTimestampBehavior to set a timestamp for record update or creation, set the corresponding attribute option to null.

By default, the update attribute is only set on record update. If you also wish it to be set on record creation, set the CTimestampBehavior::$setUpdateOnCreate option to true.

Although CTimestampBehavior attempts to figure out on it's own what value to inject into the timestamp attribute, you may specify a custom value to use instead via CTimestampBehavior::$timestampExpression

CComponent
Extended by CBehavior implements IBehavior
Extended by CModelBehavior
Extended by CActiveRecordBehavior
Extended by CTimestampBehavior
Package: zii\behaviors
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Jonah Turnquist <poppitypop@gmail.com>
Since: 1.1
Located at x2engine/framework/zii/behaviors/CTimestampBehavior.php
Methods summary
public
# beforeSave( CModelEvent $event )

Responds to CModel::onBeforeSave event. Sets the values of the creation or modified attributes as configured

Responds to CModel::onBeforeSave event. Sets the values of the creation or modified attributes as configured

Parameters

$event
CModelEvent
$event event parameter

Overrides

CActiveRecordBehavior::beforeSave()
protected mixed
# getTimestampByAttribute( string $attribute )

Gets the appropriate timestamp depending on the column type $attribute is

Gets the appropriate timestamp depending on the column type $attribute is

Parameters

$attribute
string
$attribute $attribute

Returns

mixed
timestamp (eg unix timestamp or a mysql function)
protected mixed
# getTimestampByColumnType( string $columnType )

Returns the appropriate timestamp depending on $columnType

Returns the appropriate timestamp depending on $columnType

Parameters

$columnType
string
$columnType $columnType

Returns

mixed
timestamp (eg unix timestamp or a mysql function)
Methods inherited from CActiveRecordBehavior
afterDelete(), afterFind(), afterSave(), beforeCount(), beforeDelete(), beforeFind(), events()
Methods inherited from CModelBehavior
afterConstruct(), afterValidate(), beforeValidate()
Methods inherited from CBehavior
attach(), detach(), getEnabled(), getOwner(), setEnabled()
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Properties summary
public mixed $createAttribute 'create_time'
#

The name of the attribute to store the creation time. Set to null to not use a timestamp for the creation attribute. Defaults to 'create_time'

The name of the attribute to store the creation time. Set to null to not use a timestamp for the creation attribute. Defaults to 'create_time'

public mixed $updateAttribute 'update_time'
#

The name of the attribute to store the modification time. Set to null to not use a timestamp for the update attribute. Defaults to 'update_time'

The name of the attribute to store the modification time. Set to null to not use a timestamp for the update attribute. Defaults to 'update_time'

public boolean $setUpdateOnCreate false
#

Whether to set the update attribute to the creation timestamp upon creation. Otherwise it will be left alone. Defaults to false.

Whether to set the update attribute to the creation timestamp upon creation. Otherwise it will be left alone. Defaults to false.

public mixed $timestampExpression
#

The expression that will be used for generating the timestamp. This can be either a string representing a PHP expression (e.g. 'time()'), or a CDbExpression object representing a DB expression (e.g. new CDbExpression('NOW()')). Defaults to null, meaning that we will attempt to figure out the appropriate timestamp automatically. If we fail at finding the appropriate timestamp, then it will fall back to using the current UNIX timestamp.

A PHP expression can be any PHP code that has a value. To learn more about what an expression is, please refer to the php manual.

The expression that will be used for generating the timestamp. This can be either a string representing a PHP expression (e.g. 'time()'), or a CDbExpression object representing a DB expression (e.g. new CDbExpression('NOW()')). Defaults to null, meaning that we will attempt to figure out the appropriate timestamp automatically. If we fail at finding the appropriate timestamp, then it will fall back to using the current UNIX timestamp.

A PHP expression can be any PHP code that has a value. To learn more about what an expression is, please refer to the php manual.

protected static array $map array( 'datetime'=>'NOW()', 'timestamp'=>'NOW()', 'date'=>'NOW()', )
#

Maps column types to database method

Maps column types to database method

Magic properties inherited from CActiveRecordBehavior
$owner
Magic properties inherited from CBehavior
$enabled
API documentation generated by ApiGen 2.8.0