How does Phalcon execute the native sql

How does Phalcon execute the native sql statement "LOCK TABLE table_name WRITE"; and "UNLOCK TABLES"? ??



34.7k
edited Dec '16

Hello

You can use pdo to do that here



30.0k

Hi,

I think that phalcon doesn't implement such a feature (after a quick look at https://docs.phalconphp.com/en/latest/api/Phalcon%5Db%5Dialect.html)

You will have to do that with raw sql: https://docs.phalconphp.com/en/latest/reference/phql.html#using-raw-sql

Thanks I tried; Does not work

Thanks I tried; Does not work

Is there has an function to lock table??



30.0k

What did you try exactly ?

Show code please ...

Thanks I tried; Does not work

ThinkPHP

    $table_name='autoid_'.$name;
    $auto=M($table_name);
    mysql_query("LOCK TABLES `".$table_name."` WRITE");
    $result=$auto->find();
    $autoid=$result['id'];
    $sava_id=$autoid+$num;
    $result=$auto->execute("UPDATE `".$table_name."` SET `id`='".$sava_id."'");
    mysql_query("UNLOCK TABLES");


30.0k

Hi,

Ok. So,

mysql_query("LOCK TABLES ".$table_name." WRITE");

doesn't work ? Maybe because it is a native mysql command wich is not formulated using phalcon's way. Are there any error in your webserver log ?

Also, to be sure, you may log your sql statement like this : https://docs.phalconphp.com/en/latest/reference/model-events.html#logging-low-level-sql-statements