diff --git a/extensions/sphinx/Schema.php b/extensions/sphinx/Schema.php index ad25da2..5d1fc4b 100644 --- a/extensions/sphinx/Schema.php +++ b/extensions/sphinx/Schema.php @@ -518,4 +518,15 @@ class Schema extends Object throw new Exception($message, $errorInfo, (int) $e->getCode(), $e); } } + + /** + * Returns a value indicating whether a SQL statement is for read purpose. + * @param string $sql the SQL statement + * @return boolean whether a SQL statement is for read purpose. + */ + public function isReadQuery($sql) + { + $pattern = '/^\s*(SELECT|SHOW|DESCRIBE)\b/i'; + return preg_match($pattern, $sql) > 0; + } } diff --git a/framework/db/Schema.php b/framework/db/Schema.php index fccca8f..5f36c14 100644 --- a/framework/db/Schema.php +++ b/framework/db/Schema.php @@ -520,9 +520,14 @@ abstract class Schema extends Object } } + /** + * Returns a value indicating whether a SQL statement is for read purpose. + * @param string $sql the SQL statement + * @return boolean whether a SQL statement is for read purpose. + */ public function isReadQuery($sql) { $pattern = '/^\s*(SELECT|SHOW|DESCRIBE)\b/i'; - return preg_match($pattern, $sql); + return preg_match($pattern, $sql) > 0; } }