Orange-OpenSource / YACassandraPDO

Cassandra PDO Driver fork
Apache License 2.0
85 stars 32 forks source link

no acknowledgement using $db_handle->exec('some query'); #87

Closed jayeshjain24 closed 9 years ago

jayeshjain24 commented 9 years ago

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?

sandvige commented 9 years ago

There is no supported for this, but IIRC if something get wrong, an exception is thrown

jayeshjain24 commented 9 years ago

@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.

sandvige commented 9 years ago

@jayeshjain24 what kind of error are you waiting for? This query is well formed since the table "sometable" exists

jayeshjain24 commented 9 years ago

@sandvige No. There is no table like this.I intentionally wrote it thatway. It should throw me an exception.

sandvige commented 9 years ago

@jayeshjain24 what's your CONSISTENCY level for this operation?

jayeshjain24 commented 9 years ago

@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

sandvige commented 9 years ago

@jayeshjain24 If you do a successfull insert, is it returning something different from int(0)?

jayeshjain24 commented 9 years ago

@sandvige no

sandvige commented 9 years ago

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?

jayeshjain24 commented 9 years ago

@sandvige 2.0.11

sandvige commented 9 years ago

@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?

ghost commented 9 years ago

I use this to detect errors

jayeshjain24 commented 9 years ago

@sandvige here is mine : [cqlsh 4.1.1 | Cassandra 2.0.11 | CQL spec 3.1.1 | Thrift protocol 19.39.0]

jayeshjain24 commented 9 years ago

@sandvige I am sorry.It was my fault. Just added this. $cassandraDbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); Thx for your answers.