Differential D15661 Diff 37747 src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php
Changeset View
Changeset View
Standalone View
Standalone View
src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php
| Show First 20 Lines • Show All 251 Lines • ▼ Show 20 Lines | abstract class AphrontBaseMySQLDatabaseConnection | ||||
| } | } | ||||
| protected function checkWrite($raw_query) { | protected function checkWrite($raw_query) { | ||||
| // NOTE: The opening "(" allows queries in the form of: | // NOTE: The opening "(" allows queries in the form of: | ||||
| // | // | ||||
| // (SELECT ...) UNION (SELECT ...) | // (SELECT ...) UNION (SELECT ...) | ||||
| $is_write = !preg_match('/^[(]*(SELECT|SHOW|EXPLAIN)\s/', $raw_query); | $is_write = !preg_match('/^[(]*(SELECT|SHOW|EXPLAIN)\s/', $raw_query); | ||||
| if ($is_write) { | if ($is_write) { | ||||
| if ($this->getReadOnly()) { | |||||
| throw new Exception( | |||||
| pht( | |||||
| 'Attempting to issue a write query on a read-only '. | |||||
| 'connection (to database "%s")!', | |||||
| $this->getConfiguration('database'))); | |||||
| } | |||||
| AphrontWriteGuard::willWrite(); | AphrontWriteGuard::willWrite(); | ||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| protected function throwQueryException($connection) { | protected function throwQueryException($connection) { | ||||
| if ($this->nextError) { | if ($this->nextError) { | ||||
| $errno = $this->nextError; | $errno = $this->nextError; | ||||
| $error = pht('Simulated error.'); | $error = pht('Simulated error.'); | ||||
| $this->nextError = null; | $this->nextError = null; | ||||
| ▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines | |||||