custom date_added for new subscribers

EugeneBos

New Member
Hello, how to add a custom date_added to a new subscriber object so after ->save() it will not be NOW()?

I tried
$subscriber->date_added = "2011-07-12 17:00:12"

and
$subscriber->date_added = new CDbExpression('"2011-07-12 17:00:12"');

But it both doesn't work, it ignores my properties and while saving it rewrites as with the current date...
 

EugeneBos

New Member
Solution: updating data without stupid models

PHP:
            $connection = Yii::app()->db;
            $command = $connection->createCommand('
                UPDATE {{list_subscriber}}
                    SET
                        date_added=:new_date,
                        last_updated=:new_date
                    WHERE subscriber_id=:id');

            $command->bindParam(':new_date', $details['date'], PDO::PARAM_STR);
            $command->bindParam(':id', $subscriber->subscriber_id, PDO::PARAM_STR);
            $res = $command->execute();
 
Top