Hello everyone,
I am trying to set the time automatically on a user’s table and I have the following behavior on the ActiveRecord.php file:
public function behaviors()
23 {
24 return array(
25 'CTimestampBehavior' => array(
26 'class' => 'zii.behaviors.CTimestampBehavior',
27 'createAttribute' => 'create_time',
28 'updateAttribute' => 'last_updated',
29 'setUpdateOnCreate' => true,
30 ),
31 );
32 }
This is the error I’m getting:
Trying to get property of non-object
/home/marian/mywww/TrupaPiscotel/protected/framework/zii/behaviors/CTimestampBehavior.php(107)
095 /**
096 * Gets the approprate timestamp depending on the column type $attribute is
097 *
098 * @param string $attribute $attribute
099 * @return mixed timestamp (eg unix timestamp or a mysql function)
100 */
101 protected function getTimestampByAttribute($attribute) {
102 if ($this->timestampExpression instanceof CDbExpression)
103 return $this->timestampExpression;
104 elseif ($this->timestampExpression !== null)
105 return @eval('return '.$this->timestampExpression.';');
106
107 $columnType = $this->getOwner()->getTableSchema()->getColumn($attribute)->dbType;
108 return $this->getTimestampByColumnType($columnType);
109 }
110
111 /**
112 * Returns the approprate timestamp depending on $columnType
113 *
114 * @param string $columnType $columnType
115 * @return mixed timestamp (eg unix timestamp or a mysql function)
116 */
117 protected function getTimestampByColumnType($columnType) {
118 return isset(self::$map[$columnType]) ? new CDbExpression(self::$map[$columnType]) : time();
119 }
I checked the table engine and is InnoDB. Anyting else I can check?
[size="5"]Line 107 in the error report is the highlighed one.[/size]
Any advise is much appreciated.
Marian