Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-17-2007, 01:28 PM
Junior Member
 
Join Date: Jul 2007
Posts: 1
Default Incorrect SQL produced using Zend_DB

Hi,
just recently our team decided to upgrade our Zend Framework from 0.7.0 to 1.0.0 and there have been many changes; one part more troubling than others - Zend_DB.

We use a database helper class to obtain Zend_Db objects:
$params = array( 'dbname' => _DATABASE,
'username' => _USER,
'password' => _PASSWORD,
'host' => _HOSTNAME,
'port' => _PORT,
'persistent'=> false );
$db = Zend_Db::factory( 'Db2', $params );

and retrieves Select object by:
function select () {
$db = Zend_Registry::get('DBConn');
return $db->select();
}


In the past, a piece of code was like this:
$select = database::select();
$select->from('users.users', '*');
$result = database::query($select);
return $result[0];

Now, I've changed it to
$select = database::select();
$select->from('USERS.USERS', '*');
$result = database::query($select);

and even tried
$select = database::select();
$select->from('USERS', '*', 'USERS');
$result = database::query($select);

or just
$select = database::select();
$select->from('USERS.USERS');
$result = database::query($select);

but it leads to an error (SQL0204N) saying that "USER" is an undefined name - leading me to check the SQL being produced. The SQL statement that gets run is:
SELECT "USERS".* FROM "USERS"."USERS"

Correct me if I'm wrong, but the bold part of the statement SELECT "USERS".* FROM "USERS"."USERS" is invalid when selecting all columns in a query.

Digging a bit deeper in the code, it seems like the $correlationName in __toString() in Zend/Db/Select.php seems to be 'USER' and adds it to '*' there. I must be missing something simple here.

Thanks for any insights that could be provided.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 12:22 PM.