Doctrine/symfony: getSqlQuery() output in phpMyAdmin/SQL tab

Posted by user248959 on Stack Overflow See other posts from Stack Overflow or by user248959
Published on 2010-05-28T11:53:28Z Indexed on 2010/05/28 12:31 UTC
Read the original article Hit count: 288

Filed under:
|
|

Hi,

i have created this query that works OK:

$q1 = Doctrine_Query::create()
     ->from('Usuario u')
     ->leftJoin('u.AmigoUsuario a ON u.id = a.user2_id OR u.id = a.user1_id')
     ->where("a.user2_id = ? OR a.user1_id = ?", array($id,$id))
     ->andWhere("u.id <> ?", $id)
     ->andWhere("a.estado LIKE ?", 1);

echo $q1->getSqlQuery();

The calling to getSqlQuery outputs this clause:

SELECT s.id AS s_id, s.username AS s_username, s.algorithm AS s_algorithm, s.salt AS s_salt, s.password AS s__password, s.is_active AS s__is_active, s.is_super_admin AS s__is_super_admin, s.last_login AS s__last_login, s.email_address AS s__email_address, s.nombre_apellidos AS s__nombre_apellidos, s.sexo AS s__sexo, s.fecha_nac AS s__fecha_nac, s.provincia AS s_provincia, s.localidad AS s_localidad, s.fotografia AS s_fotografia, s.avatar AS s_avatar, s.avatar_mensajes AS s__avatar_mensajes, s.created_at AS s__created_at, s.updated_at AS s__updated_at, a.id AS a__id, a.user1_id AS a__user1_id, a.user2_id AS a__user2_id, a.estado AS a__estado FROM sf_guard_user s LEFT JOIN amigo_usuario a ON ((s.id = a.user2_id OR s.id = a.user1_id)) WHERE ((a.user2_id = ? OR a.user1_id = ?) AND s.id <> ? AND a.estado LIKE ?)

If i take that clause to phpmyadmin SQL tab i get this error

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? OR a.user1_id = ?) AND s.id <> ? AND a.estado LIKE ?) LIMIT 0, 30' at line 1

Why i'm getting this error?

Regards

Javi

© Stack Overflow or respective owner

Related posts about query

Related posts about symfony