IMPORTANT: Without real master/slave setup we can only test, that in our fake master/slave setup slave is chosen for SELECT queries.
Code fragment
$application->Conn->Query('SELECT * FROM inp_SlaveOnly');
- in Database Manager:
- create new database as copy/paste from database used in In-Portal
- in copied database create inp_SlaveOnly database table
- remember created database name
- in IDE:
- open /index.php file for editing (front-end)
- after $application->Init(); line add code shown above test plan
- save changes
- change /system/config.php file to:
- enable support for load balancing (see example in http://community.in-portal.org/x/Npkk and you can use same server as both slave & master) with DBMaxLag key in slave config set to 15 (any positive non-zero number really)
- for slave connection add DBName key (even though it's not listed in Confluence) with above copied database name
- basically what we need is inp_SlaveOnly table to be present on slave (copied) database only, but not on master database
- in core/kernel/db/db_load_balancer.php file change \kDBLoadBalancer::reallyOpenConnection method change $this->servers[0]['DBName'] to $server['DBName'] (allows to use different DB name for slave, that was added in config.php file)
- in IDE
- enable Debug Mode
- in Web Browser
- open Front-End
- confirm, that no SQL error happened
- in IDE
- disable Debug Mode
- in Web Browser
- open Front-End
- confirm, that no SQL error happened