In this way I should replace all db-default timestamps or I'll compare
application time with db-time and they can be different (db-server is
separated from application server)

I've override AppModel with own class

class AppModel extends Model{

    var $now = 'NOW()'; // mysql

    function __construct()
    {
        parent::__construct();
        $dbConfig = new DATABASE_CONFIG;
        if($dbConfig->default['driver'] == 'mssql')
            $this->now = 'GETDATE()';
    }
}

and use $this->now in Models, but it doesn't look very good.
I hoped cake contains analog of this functionality for any db-driver,
but it seems as not.

2008/12/3 Smelly_Eddie <[EMAIL PROTECTED]>:
>
> how about
>
> $currentTime = date('Y-m-d h:i:s');  //check the format for the date
> command, I may be off.
>
> Then use $currentTime in your query....
>
> On Dec 2, 8:47 am, Alexey Grunichev <[EMAIL PROTECTED]> wrote:
>> Does cake contain any functionality to pass as parametr in condition
>> function current time?
>> I need a query such as:
>> Select * from ... where exp_datetime < NOW()
>> If I passexp_datetime < NOW() in condition it won't work in MSSQL (it
>> used GETDATE())
>> I need a cross-db solution.
>>
>> I can use application time, but app and db could be located at
>> different physical servers in different time zones and in this way I
>> should replace all used default timestamps functionality in db.
>>
>> So, I wonder to know, does cake contain functionality to pass as
>> current time function as condition in Model?
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to