cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[BUG]: forUpdate not use writeConnectionService

Open itbdw opened this issue 2 years ago • 0 comments

Describe the bug The code use the readConnectionService when I wrote the forUpdate(true) code, which should use the writeConnectionService.

To Reproduce

make a read/write mysql database

set the read instance readonly

public static function testSlaveForUpdate($bool) {
        $model = new UserAccount();

        $model->setWriteConnectionService("write"); //write db
        $model->setReadConnectionService("read"); //read db

        $model->query()->where("id = 1")->forUpdate($bool)->execute();
    }

Provide minimal script to reproduce the issue

run the code and got exception

PDOException with message 'SQLSTATE[HY000]: General error: 1290 The MySQL server is running with the --read-only option so it cannot execute this statement'

Expected behavior

use the writeConnectionService

Screenshots If applicable, add screenshots to help explain your problem.

Details

  • Phalcon version: (3.4.5)
  • PHP Version: (PHP 7.1)
  • Operating System: Ubuntu 16.04
  • Installation type: Compiling from source
  • Zephir version (if any):
  • Server: Nginx
  • Other related info (Database, table schema):

Additional context

itbdw avatar Jul 27 '22 18:07 itbdw