Hi,

On 3/5/07, Adam Balgach <[EMAIL PROTECTED]> wrote:

I am trying to form the query:

Select firstname, lastname, email from table where user_id = 1

so when i do:

    $select=$this->_db->select();
    $select->from('table', 'table.firstname ');
    $select->from('table', 'table.lastname');
    $select->from('table', 'table.email');
    $select->where('table.user_id = '.$userId);

it is generating this query:

 SELECT
        table.`firstname`,
        table_2.`lastname`,
        table_3.`email`
FROM `table` table
 INNER JOIN `table` table_2
 INNER JOIN `table` table_3
WHERE
      table.user_id = 11


which clearly does not return the same result.  Is this a bug?  Or am I
using select incorrectly.


The right ways is to use the following:
$select=$this->_db->select();
$select->from('table', array('firstname', 'lastname', 'email'));
$select->where($this->_db->quoteInto('user_id = ?', $userId));

Sincerely,

--
Alexander
http://www.alexatnet.com/

Reply via email to