mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-05 11:02:40 +00:00
Allowing multiple sql sentences to be executed only for creting or altering databases
This commit is contained in:
parent
09487f830c
commit
0ffe6de9e4
2 changed files with 10 additions and 1 deletions
|
@ -321,6 +321,15 @@ class DboSource extends DataSource {
|
|||
* query returning no rows, suchs as a CREATE statement, false otherwise
|
||||
*/
|
||||
protected function _execute($sql, $params = array()) {
|
||||
$sql = trim($sql);
|
||||
if (preg_match('/^CREATE|^ALTER|^DROP/i', $sql)) {
|
||||
$statements = array_filter(explode(';', $sql));
|
||||
if (count($statements) > 1) {
|
||||
$result = array_map(array($this, '_execute'), $statements);
|
||||
return array_search(false, $result) === false;
|
||||
}
|
||||
}
|
||||
|
||||
$query = $this->_connection->prepare($sql);
|
||||
$query->setFetchMode(PDO::FETCH_LAZY);
|
||||
if (!$query->execute($params)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue