CI_DB_driver::is_write_type PHP Method

is_write_type() public method

Determines if a query is a "write" type.
public is_write_type ( $sql ) : boolean
return boolean
    public function is_write_type($sql)
    {
        return (bool) preg_match('/^\\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\\s/i', $sql);
    }

Usage Example

Example #1
0
 /**
  * Determines if a query is a "write" type.
  *
  * @param	string	An SQL query string
  * @return	bool
  */
 public function is_write_type($sql)
 {
     if (preg_match('#^(INSERT|UPDATE).*RETURNING\\s.+(\\,\\s?.+)*$#is', $sql)) {
         return FALSE;
     }
     return parent::is_write_type($sql);
 }