PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB_DataObject » Bug #1926

DB_DataObject datetime

Details

Submitted2004-07-20 15:18 UTC
Frommoander at atc dot no
StatusBogus
PackageDB_DataObject
PHP Version4.3.7
OSWindows
Roadmaps(Not assigned)

Comments

[2004-07-20 15:18 UTC] moander at atc dot no

Description:
------------
$u = new User();

$u->registered = datetime(); // Returns xxxx-xx-xx xx:xx:xx
$u->cellphone = "48044410";
$u->nickname = "MyNick";
$u->insert();

1. I had to set 'registered' => DB_DATAOBJECT_STR in the table() function. I have tested DB_DATAOBJECT_DATE and DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME.

2. I want to set registered to the mysql function now() on insert. I also want to set lastchange to now() when I run the update() function.

3. After this insert I have a record in my table with userId 14. $u->get(14) is not working. No error, just a empty object with var $userId = 14..

Reproduce code:
---------------
class User extends DB_DataObject {
var $userId = 0;
var $registered = "";
var $nickname = "";
var $cellphone = "";
var $password = "";
var $__table = "user";

function table()
{
return array(
'userId' => DB_DATAOBJECT_INT,
'registered' => DB_DATAOBJECT_STR,
'nickname' => DB_DATAOBJECT_STR,
'cellphone' => DB_DATAOBJECT_INT,
'password' => DB_DATAOBJECT_STR);
}

function keys()
{
return array('userId');
}
}