duoshuo / php-cassandra

php Cassandra driver which support Protocol v3 (Cassandra 2.1) and asynchronous requests
MIT License
153 stars 53 forks source link

problem with running IN in where clause with array #75

Open dileepmaurya opened 8 years ago

dileepmaurya commented 8 years ago

I have table structure like this

CREATE TABLE mycdb.emp_details (
    id uuid PRIMARY KEY,
    age int,
    name text
)

and try to run CQL ad below

$ids = ['388caf5e-fdef-4922-9b73-88363a28140f', '0f6a5834-7194-45a7-9755-e28b20351af7']
$rs = $connection->querySync('select * from emp_details where id in(:ids)', ['ids' => $ids]);

its throw Cassandra\Type\Exception with message '$values should be an sequential array, associative array given. Or you can set "names_for_values" option to true.'

correct me if i am wrong right now there is no any possibility to pass array in IN clause if not could we improve that.

CBox commented 7 years ago

try changing to: $rs = $connection->querySync('select * from emp_details where id in(:ids)', ['ids' => $ids], null, ['names_for_values' => true]);