Monday, March 2, 2009

query - different results (fetching) in mysql/mssql

I need to have application that can work in either MySQL or MSSQL
environment.
Due to db-abstractions all work fine if I'm using find() and other
methods.
But sometimes I need to use query() function for big and hard queries.
Here I have one issue.
I'm going to use simple examples, of course real queries are
different.
var_dump($this->MyModel->query("SELECT * FROM users as u,
user_sessions as us"));

Mysql returns:
array
0 =>
array
'u' =>
array
'id' => string '1' (length=1)
'username' => string 'test' (length=4)
'password' => string 'password' (length=40)
'us' =>
array
'id' => string '1' (length=1)
'user_id' => string '1' (length=1)
'created' => string '2009-03-02 15:20:28' (length=19)
'closed' => null
'last_update' => null
'last_save' => null

MSSQL returns:
array
0 =>
array
0 =>
array
'id' => string '1' (length=1)
'username' => string 'test' (length=4)
'password' => string 'password' (length=40)
'user_id' => string '1' (length=1)
'created' => string 'Dec 29 2008 5:08PM' (length=19)
'closed' => null
'last_update' => null
'last_save' => null

So, first thing - we don't have aliases, second thing - mssql merged
both tables output in one array.

If I use find() alises work fine in MSSQL (as well as in MySQL), how
can this problem be solved for query() function?

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

No comments: