2 newbie Qs: DB_DataObjects
| From: | C.J. Mackie | Date: | Wed, 15 Jun 2005 15:10:01 +0000 |
| Subject: | 2 newbie Qs: DB_DataObjects | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-19634@lists.php.net to get a copy of this message | ||
I'm setting up DB_DO on PHP5/MySQL4. I've got most things working, but I've
run into a couple of quirks on which I could use some help.
1) is it possible to force DB_DO to use PEAR sequences for inserts to MySQL?
The docs say it uses PEAR sequences for every db except MySQL. I'm using
PEAR sequences already, and need to continue doing so. I can always get the
sequence #s and add them manually, but it seems more elegant to ask DB_DO to
use them itself, if possible.
2) Everything else seems to be working fine except for date parsing, which
isn't working at all. I try to insert a record that contains a 'CreateDate'
field, and MySQL inserts a default (0000-00-00 00:00:00, to be precise).
I've tried formatting the correct insert string many different ways, and
I've tried passing through the NOW() function, but neither works. Here's
the example code:
$u = DB_DataObject::Factory('users');
$testID = $dbh->nextID('users');
$u->ID = $testID;
... fill in other fields here ...
$my_timestamp = strftime("%Y-%m-%d %H:%M:%S");
$u->CreateDate = $my_timestamp;
$u->insert();
$u->update();
Can anyone tell me what I'm doing wrong? (n.b., I've looked at the
'DB_DO::Cast' objects as a solution, but I'm not allowed to use code labeled
as 'beta'.)
Many thanks, and apologies in advance if I missed a FAQ somewhere, --CJ