Re: inserting DATE's using DB_DataObject 1.7.10
| From: | Yashesh Bhatia | Date: | Thu, 17 Mar 2005 09:12:37 +0000 |
| Subject: | Re: inserting DATE's using DB_DataObject 1.7.10 | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-18100@lists.php.net to get a copy of this message | ||
ooops i think the some attachments did not go thru but here's the main one. test1.php
require_once 'configDB.php';
require_once 'DataObjects/User.php';
$user = new DataObjects_User();
$user->name = "Foo Bar";
$user->dob = "1980-25-10";
$user->income = 15000;
$user->insert();
if i use
$user->dob = DB_DataObject_Cast::date("1980-25-10");
the insert works fine. so why is it that we need to
use a cast for the datatype "DATE" ...
thank you.
yashesh.
Yashesh Bhatia wrote:
hello:-- go pre http://www2.localaccess.com/rlalonde/pre.htmi'm trying to insert a field of type DATE into the table using DB_DataObject 1.7.10 but it does not insert it.here's my setup. OS : Fedora Core 2 PHP : 5.0.3 Mysql Server version: 5.0.2-alpha for pc-linux (i686) PEAR 1.3.4 stable DB 1.7.4 stable DB_DataObject 1.7.10 stable being a newbie i tried borrowed code/help from the article http://www.onlamp.com/pub/a/php/2004/12/09/three_tier.html so here's what i did. 1 - created an example.ini file 2 - created a database (db_dataobjects) and a table (user) 3 - ran the generator [yvb@bfc11 ex1]$ php /usr/local/php5/lib/php/DB/DataObject/createTables.php example.ini 4 - ran a test script to insert a record into the database. now i checked my database and instead of getting "1980-25-10" i get the date as 0000-00-00. i would appreciate if anyone can help me fix the problem and also why a valid string is not inserted into the mysql db. i've attached the following files.- example.ini - main config file - User.php - generated class file- db_dataobject.ini - generated schema file - configDB.php - application wide include file - test1.php - test script thx a lot in advance. rgd. yasheshb. ------------------------------------------------------------------------ [DB_DataObject]database = mysql://db_dataobject:test12345@localhost/db_dataobjectschema_location = /home/yvb/work/practice/php/PEAR/db_dataobject/ex1/DataObjects class_location = /home/yvb/work/practice/php/PEAR/db_dataobject/ex1/DataObjects require_prefix = DataObjects/class_prefix = DataObjects_------------------------------------------------------------------------ [user] id = 129 name = 130 dob = 134 income = 129 [user__keys] id = N