Seems like this should be the easy part, but I can't seem to get this going. My created
and updated
fields are not being populated. I've tried renaming the fields to something different, but no go. Other than the schema and setting up the class (very basic) as below, am I missing something?
Codeigniter v2.1.2 Datamapper ORM v1.8.2.1
Schema:
CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`created` datetime NOT NULL,
`updated` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1
User Class:
<?php
class User extends DataMapper
{
function User()
{
parent::DataMapper();
}
}
Ok, found the answer and hopefully this will help someone out. I needed to set the following in the application/config/datamapper.php file:
$config['local_time'] = TRUE;
$config['unix_timestamp'] = FALSE;
$config['timestamp_format'] = 'Y-m-d H:i:s';
In your config/datamapper.php file ensure 'created_field' and 'updated_field' are set to match your DB columns. Or you can override them in the model itself. ie.
<?php
class User extends DataMapper
{
var $created_field = 'created';
var $updated_field = 'updated';
function User()
{
parent::DataMapper();
}
}