Closed jayeshjain24 closed 9 years ago
There is no supported for this, but IIRC if something get wrong, an exception is thrown
@sandvige no there is no exception. I verified it by firing a wrong query. but it does not throw any exception.
$query = "INSERT INTO sometable(a,b,c,d) VALUES ('6577aa99-ccb7-492c-a4cd-051ff4a893ab',1,1,{4,12,96},4444);";
try{
var_dump($cassandraDbh->exec($query));
}catch(Exception $e){
echo $e->getMessage();
throw new Exception('not inserted');
}
Ideally this query should throw an exception. But in reality it doesnt.
@jayeshjain24 what kind of error are you waiting for? This query is well formed since the table "sometable" exists
@sandvige No. There is no table like this.I intentionally wrote it thatway. It should throw me an exception.
@jayeshjain24 what's your CONSISTENCY level for this operation?
@sandvige I am not setting any consistency level explicitly. So I think it should use the default consistency. But I dont think that is the issue here.
Irrespective whether everything is correct or not, this int(0)
is what I get as result when i var_dump()
it
@jayeshjain24 If you do a successfull insert, is it returning something different from int(0)?
@sandvige no
Here is something I tried on my side, and everything is working as expected:
api@api02:~$ php app/console doctr:query:sql --connection="cassandra" "INSERT INTO sometable(a,b,c,d) VALUES ('6577aa99-ccb7-492c-a4cd-051ff4a893ab',1,1,{4,12,96},4444);"
[Doctrine\DBAL\DBALException]
An exception occurred while executing 'INSERT INTO sometable(a,b,c,d) VALUES ('6577aa99-ccb7-492c-a4cd-051ff4a893ab',1,1,{4,12,96},4444);':
CQLSTATE[HY000] [2] unconfigured columnfamily sometable
[PDOException]
CQLSTATE[HY000] [2] unconfigured columnfamily sometable
doctrine:query:sql [--depth="..."] [--connection[="..."]] sql
What version of Cassandra are you using?
@sandvige 2.0.11
@jayeshjain24 Here is mine: [cqlsh 4.1.1 | Cassandra 2.0.11.83 | DSE 4.6.0 | CQL spec 3.1.1 | Thrift protocol 19.39.0]
What source version are you using for the driver? The latest?
I use this to detect errors
@sandvige here is mine : [cqlsh 4.1.1 | Cassandra 2.0.11 | CQL spec 3.1.1 | Thrift protocol 19.39.0]
@sandvige I am sorry.It was my fault. Just added this. $cassandraDbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); Thx for your answers.
How do I know whether the operation is successful or not.
When I try to store the result of
$result = $db_handle->exec('some query'); var_dump($result)
.It always gives me int(0) even when the operation is succesful.Is there any way to get the correct acknowledgement?