$paymentData = array(
'DATE' => new Zend_Db_Expr('SYSDATE'),
'USERID' => $userId,
'AMOUNT' => $amount
);
On Thu, Apr 2, 2009 at 7:09 AM, Thomas Weidner <thomas.weidner@gmx.at> wrote:
> There are two ways:
>
> Eighter use getTimestamp to store the date as unix timestamp. Note that
> databases as also Zend_Date supports negative timestamps and timestamps
> beyond 32bit integer.
>
> Or use toString() and get the format you want to have manually...
> (toString('dd.MM.yyyy HH:mm:ss') for example)
>
> There are issues to add dbagnostic date format to Zend_Db, but they are
> actually not solved and have not much users which voted for them.
>
> Greetings
> Thomas Weidner, I18N Team Leader, Zend Framework
> http://www.thomasweidner.com
>
> ----- Original Message ----- From: "Daryl Handley" <darylhandley@gmail.com>
> To: <fw-db@lists.zend.com>
> Sent: Thursday, April 02, 2009 1:37 AM
> Subject: [fw-db] Storing a Zend_Date in a Zend_Db_Table
>
>
>> I'm trying to store a date in a db table (using Oracle) and it fails
>> telling
>> me.
>>
>> ORA-01858: a non-numeric character was found where a numeric was expected
>>
>> My code looks something like this
>>
>> $paymentData = array(
>> 'DATE' => Zend_Date::now(),
>> 'USERID' => $userId,
>> 'AMOUNT' => $amount
>> );
>> $paymentDbTable = new PaymentDbTable();
>> $paymentDbTable->insert($paymentData);
>>
>> I've also tried using Zend_Date::now()->getIso() and it doesn't like that
>> much either (ORA-01861: literal does not match format string).
>>
>> I have a couple of workarounds but I don't really like either of them
>> because they kind of tie it to Oracle (format into a string literal that
>> Oracle likes or use a Zend_Db_Expr('SYSDATE'). In Java this was pretty
>> simple and you just pass the date and the adapter layer figures out what
>> to
>> do. I've got to think there must be an easy db agnostic way to do it in
>> Zend
>> as well.
>>
>> Thanks
>> Daryl
>>
>
>
--
Thomas VEQUAUD http://thomas.vequaud.free.fr/
Expert EPITECH en Ingénierie Informatique
Tél : +33(0)6.50.39.28.10 Fax: +33(0)9.58.46.10.07
没有评论:
发表评论