#1020: Can't pass comma separated fields on a single parameter query
The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From:
"Doctrine" <no-re... @phpdoctrine.org>
Date: Wed, 07 May 2008 09:29:51 -0000
Local: Wed 7 May 2008 10:29
Subject: [Doctrine] #1020: Can't pass comma separated fields on a single parameter query
#1020: Can't pass comma separated fields on a single parameter query
------------------------+-------------------------------------------------- -
Reporter: teixi | Owner: jwage
Type: defect | Status: new
Priority: minor | Milestone: 0.11.2
Component: Attributes | Version: 0.11
Keywords: |
------------------------+-------------------------------------------------- -
Imagine this kind of query:
$q = new Doctrine_Query();
$q->from(' Users u ')
->where(' u.id in (?) ');
$q->fetchArray(array('8,3,5,7'));
And the sql is only looking for users with id 8 but not 3, 5 and 7
-- Ticket URL: <http://trac.phpdoctrine.org/ticket/1020 >
Doctrine <http://www.phpdoctrine.org >
PHP Doctrine Object Relational Mapper
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"Doctrine" <no-re... @phpdoctrine.org>
Date: Sat, 10 May 2008 03:39:33 -0000
Local: Sat 10 May 2008 04:39
Subject: Re: [Doctrine] #1020: Can't pass comma separated fields on a single parameter query
#1020: Can't pass comma separated fields on a single parameter query
-------------------------+------------------------------------------------- -
Reporter: teixi | Owner: jwage
Type: defect | Status: new
Priority: minor | Milestone: 0.11.2
Component: Attributes | Version: 0.11
Resolution: | Keywords:
-------------------------+------------------------------------------------- -
Comment (by jwage):
Hmm. This should work. Can you provide a failing test case?
-- Ticket URL: <http://trac.phpdoctrine.org/ticket/1020#comment:1 >
Doctrine <http://www.phpdoctrine.org >
PHP Doctrine Object Relational Mapper
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"Doctrine" <no-re... @phpdoctrine.org>
Date: Sat, 10 May 2008 20:59:13 -0000
Local: Sat 10 May 2008 21:59
Subject: Re: [Doctrine] #1020: Can't pass comma separated fields on a single parameter query
#1020: Can't pass comma separated fields on a single parameter query
-------------------------+------------------------------------------------- -
Reporter: teixi | Owner: jwage
Type: defect | Status: new
Priority: minor | Milestone: 0.11.2
Component: Attributes | Version: 0.11
Resolution: | Keywords:
-------------------------+------------------------------------------------- -
Comment (by teixi):
Dear Jonathan,[[BR]]
[[BR]]
If you create database and mappings as of my tutorial
http://www.teixi.net/hands_on_doctrine/ [[BR]]
[[BR]]
then add this simple query:[[BR]]
$c=array('ca_ES','es_ES','en_US');[[BR]]
$q = new Doctrine_Query();[[BR]]
$q->from(' SysLang sl ')->where(' sl.id in (?) ');[[BR]]
$q->fetchArray($c); [[BR]]
[[BR]]
produces:[[BR]]
[[BR]]
Fatal error: Uncaught exception 'Doctrine_Connection_Mysql_Exception' with
message 'SQLSTATE[HY093]: [[BR]]
Invalid parameter number: number of bound variables does not match number
of tokens' in [[BR]]
/home/teixi/workspace/resources/Doctrine-0.11.0-RC2/Doctrine-0.11.0/lib/Doc trine/Connection.php:1050
[[BR]]
Stack trace: #0 [[BR]]
/home/teixi/workspace/resources/Doctrine-0.11.0-RC2/Doctrine-0.11.0/lib/Doc trine/Connection/Statement.php(244):
[[BR]]
Doctrine_Connection->rethrowException(Object(PDOException),
Object(Doctrine_Connection_Statement)) #1 [[BR]]
/home/teixi/workspace/resources/Doctrine-0.11.0-RC2/Doctrine-0.11.0/lib/Doc trine/Connection.php(979):
[[BR]]
Doctrine_Connection_Statement->execute(Array) #2 [[BR]]
/home/teixi/workspace/resources/Doctrine-0.11.0-RC2/Doctrine-0.11.0/lib/Doc trine/Query/Abstract.php(948):
[[BR]]
Doctrine_Connection->execute('SELECT s.id AS ...', Array) #3 [[BR]]
/home/teixi/workspace/resources/Doctrine-0.11.0-RC2/Doctrine-0.11.0/lib/Doc trine/Query/Abstract.php(994):
[[BR]]
Doctrine_Query_Abstract->_ex in [[BR]]
/home/teixi/workspace/resources/Doctrine-0.11.0-RC2/Doctrine-0.11.0/lib/Doc trine/Connection.php
on line 1050[[BR]]
-- Ticket URL: <http://trac.phpdoctrine.org/ticket/1020#comment:2 >
Doctrine <http://www.phpdoctrine.org >
PHP Doctrine Object Relational Mapper
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"Doctrine" <no-re... @phpdoctrine.org>
Date: Sat, 10 May 2008 21:00:16 -0000
Local: Sat 10 May 2008 22:00
Subject: Re: [Doctrine] #1020: Can't pass comma separated fields on a single parameter query
#1020: Can't pass comma separated fields on a single parameter query
-------------------------+------------------------------------------------- -
Reporter: teixi | Owner: jwage
Type: defect | Status: new
Priority: minor | Milestone: 0.11.2
Component: Attributes | Version: 0.11
Resolution: | Keywords:
-------------------------+------------------------------------------------- -
Comment (by teixi):
the editor in here adds a question mark on SysLang when in fact my query
whas 'SysLang sl' whithout question mark.
-- Ticket URL: <http://trac.phpdoctrine.org/ticket/1020#comment:3 >
Doctrine <http://www.phpdoctrine.org >
PHP Doctrine Object Relational Mapper
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"Doctrine" <no-re... @phpdoctrine.org>
Date: Sat, 10 May 2008 21:19:53 -0000
Local: Sat 10 May 2008 22:19
Subject: Re: [Doctrine] #1020: Can't pass comma separated fields on a single parameter query
#1020: Can't pass comma separated fields on a single parameter query
-------------------------+------------------------------------------------- -
Reporter: teixi | Owner: jwage
Type: defect | Status: closed
Priority: minor | Milestone: 0.11.2
Component: Attributes | Version: 0.11
Resolution: invalid | Keywords:
-------------------------+------------------------------------------------- -
Changes (by romanb):
* status: new => closed
* resolution: => invalid
Comment:
Even though this should work on mysql (i dont know why it doesnt in your
case), it's really ugly. Every other dbms will correctly complain, i.e.
postgres will throw an error saying that it's an incorrect type (using a
string parameter in the IN clause). You need to have as many placeholders
in your statement as there are parameters.
Maybe even Mysql has stopped supporting this behavior at some point, i
don't know why it's not working for you.
Either way, this has nothing to do with Doctrine, you can use whereIn()
and that will properly generate as many placeholders as there are
parameters.
-- Ticket URL: <http://trac.phpdoctrine.org/ticket/1020#comment:4 >
Doctrine <http://www.phpdoctrine.org >
PHP Doctrine Object Relational Mapper
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"Doctrine" <no-re... @phpdoctrine.org>
Date: Sun, 11 May 2008 01:02:41 -0000
Local: Sun 11 May 2008 02:02
Subject: Re: [Doctrine] #1020: Can't pass comma separated fields on a single parameter query
#1020: Can't pass comma separated fields on a single parameter query
-------------------------+------------------------------------------------- -
Reporter: teixi | Owner: jwage
Type: defect | Status: closed
Priority: minor | Milestone: 0.11.2
Component: Attributes | Version: 0.11
Resolution: invalid | Keywords:
-------------------------+------------------------------------------------- -
Comment (by jwage):
Well, I don't see how this would ever work:
{{{
$c=array('ca_ES','es_ES','en_US');
$q = new Doctrine_Query();
$q->from(' SysLang? sl ')->where(' sl.id in (?) ');
$q->fetchArray($c);
}}}
You have one place holder and 3 values in the array. This exception comes
from PDO and is expected.
-- Ticket URL: <http://trac.phpdoctrine.org/ticket/1020#comment:5 >
Doctrine <http://www.phpdoctrine.org >
PHP Doctrine Object Relational Mapper
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"Doctrine" <no-re... @phpdoctrine.org>
Date: Sun, 11 May 2008 12:51:31 -0000
Local: Sun 11 May 2008 13:51
Subject: Re: [Doctrine] #1020: Can't pass comma separated fields on a single parameter query
#1020: Can't pass comma separated fields on a single parameter query
-------------------------+------------------------------------------------- -
Reporter: teixi | Owner: jwage
Type: defect | Status: closed
Priority: minor | Milestone: 0.11.2
Component: Attributes | Version: 0.11
Resolution: invalid | Keywords:
-------------------------+------------------------------------------------- -
Comment (by teixi):
I try to reproduce multi comma separated values inside a 'where in'
statement which is in fact valid sql for mysql, postgres or oracle
SELECT * FROM users WHERE users.id IN (10,11,12)
How could one implement this with Doctrine ?
-- Ticket URL: <http://trac.phpdoctrine.org/ticket/1020#comment:6 >
Doctrine <http://www.phpdoctrine.org >
PHP Doctrine Object Relational Mapper
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"Doctrine" <no-re... @phpdoctrine.org>
Date: Thu, 15 May 2008 16:00:54 -0000
Local: Thurs 15 May 2008 17:00
Subject: Re: [Doctrine] #1020: Can't pass comma separated fields on a single parameter query
#1020: Can't pass comma separated fields on a single parameter query
-------------------------+------------------------------------------------- -
Reporter: teixi | Owner: jwage
Type: defect | Status: reopened
Priority: minor | Milestone: 0.11.1
Component: Attributes | Version: 0.11
Resolution: | Keywords:
-------------------------+------------------------------------------------- -
Changes (by teixi):
* status: closed => reopened
* resolution: invalid =>
* milestone: 0.11.2 => 0.11.1
Comment:
I just reopen this for next release, please read my last comment.
-- Ticket URL: <http://trac.phpdoctrine.org/ticket/1020#comment:7 >
Doctrine <http://www.phpdoctrine.org >
PHP Doctrine Object Relational Mapper
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"Doctrine" <no-re... @phpdoctrine.org>
Date: Thu, 15 May 2008 17:18:23 -0000
Local: Thurs 15 May 2008 18:18
Subject: Re: [Doctrine] #1020: Can't pass comma separated fields on a single parameter query
#1020: Can't pass comma separated fields on a single parameter query
-------------------------+------------------------------------------------- -
Reporter: teixi | Owner: jwage
Type: defect | Status: closed
Priority: minor | Milestone: 0.11.1
Component: Attributes | Version: 0.11
Resolution: invalid | Keywords:
-------------------------+------------------------------------------------- -
Changes (by romanb):
* status: reopened => closed
* resolution: => invalid
Comment:
What you do:
{{{
$q = new Doctrine_Query();
$q->from(' Users u ') ->where(' u.id in (?) ');
$q->fetchArray(array('8,3,5,7'));
}}}
What you should do:
{{{
$q = new Doctrine_Query();
$q->from(' Users u ') ->where(' u.id in (?,?,?,?) ');
$q->fetchArray(array(8,3,5,7));
}}}
Or:
{{{
$q = new Doctrine_Query();
$q->from(' Users u ') ->whereIn('u.id', array(8,3,5,7));
$q->fetchArray();
}}}
-- Ticket URL: <http://trac.phpdoctrine.org/ticket/1020#comment:8 >
Doctrine <http://www.phpdoctrine.org >
PHP Doctrine Object Relational Mapper
You must
Sign in before you can post messages.
You do not have the permission required to post.