ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:loadbalancer:isreadonlyquery

isReadOnlyQuery

Applies To

ADOdb Load Balancer

Syntax
 bool isReadOnlyQuery(
       string $sql
       )

Description

The method isReadOnly() reads a provided SQL statement for elements that might cause a read-write process to be created. The method is used internally by the load balancer to determine if a statement needs to be executed on the primary server but can also be called manually.


Usage

/*
* connection to load balancer assumed
*/
 
$SQL = "SELECT * FROM employees";
 
print $db->isReadOnlySql($SQL);
 
/*
* Returns false
*/
 
SQL = "SELECT * FROM employees FOR UPDATE";
 
print $db->isReadOnlySql($SQL);
 
/*
* Returns true
*/
v5/reference/loadbalancer/isreadonlyquery.txt · Last modified: 2017/04/25 01:12 by mnewnham