tags:

views:

50

answers:

1

Params:

$params = 2826558;                        # Necessary Object
$params = array(2826558,2677805,2636005); # NULL

Execution code:

    $data = $this->DQL_selectAllByCampaign_id()
                 ->execute( array($params) )
                 ->fetchAll();

    var_dump( $data );

SQL Query:

$this->DQL_selectAllByCampaign_id = $this->conn->prepare(

        "SELECT * FROM `banner` WHERE  `campaign_id` IN (?)"

);

If $params is Integer, returns necessary Object. If $params is Array, returns NULL.

After all, in fact it should work... How can I do that?

+1  A: 

I'm quite sure this isn't the 'right' answer, but we solved this by adding in count($array) placeholders. Then using call_user_func_array we pass the params in.

Thanks for asking this - will be interesing to find out what the proper way to do this is...

kander
I found the solution of which you speak - http://www.php.net/manual/en/pdo.prepare.php. Apparently this is really the most common solution. But it is a crutch. I'll look for a solution more beautiful than this, and yet do so.
HWTech