Skip to content
Snippets Groups Projects
Commit 5c47f144 authored by Giovannoni Laurent's avatar Giovannoni Laurent
Browse files

FEAT #4576 delete ref to class dbquery

parent d790b2be
No related branches found
No related tags found
No related merge requests found
...@@ -275,12 +275,13 @@ class Database extends functions ...@@ -275,12 +275,13 @@ class Database extends functions
* @param string $queryString The SQL query string * @param string $queryString The SQL query string
* @param array $parameters An indexed or associative array of parameters * @param array $parameters An indexed or associative array of parameters
* @param bool $catchExceptions Indicates wheter the PDO exceptions must be caught * @param bool $catchExceptions Indicates wheter the PDO exceptions must be caught
* @param bool $multi Indicates wheter multi queries likes in sql file is required
* *
* @return PDOStatement The prepared and executed statement * @return PDOStatement The prepared and executed statement
* *
* @throws PDOException If a PDO error occurs during preparation or execution * @throws PDOException If a PDO error occurs during preparation or execution
*/ */
public function query($queryString, $parameters=null, $catchExceptions=false) public function query($queryString, $parameters=null, $catchExceptions=false, $multi=false)
{ {
if ($parameters) { if ($parameters) {
foreach ($parameters as $key => $value) { foreach ($parameters as $key => $value) {
...@@ -317,32 +318,36 @@ class Database extends functions ...@@ -317,32 +318,36 @@ class Database extends functions
} }
} }
try { if ($multi) {
$this->stmt = $this->prepare($queryString); $this->pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
preg_match_all("/\?|\:/", $queryString, $matches, PREG_OFFSET_CAPTURE); $this->pdo->exec($queryString);
if (empty($matches[0])) { return true;
//echo $queryString; } else {
$executed = $this->stmt->execute(); try {
} else { $this->stmt = $this->prepare($queryString);
$executed = $this->stmt->execute($parameters); preg_match_all("/\?|\:/", $queryString, $matches, PREG_OFFSET_CAPTURE);
} if (empty($matches[0])) {
//echo $queryString;
$executed = $this->stmt->execute();
} catch (PDOException $PDOException) { } else {
if ($catchExceptions) { $executed = $this->stmt->execute($parameters);
$this->error = $PDOException->getMessage(); }
} catch (PDOException $PDOException) {
if ($catchExceptions) {
$this->error = $PDOException->getMessage();
return false; return false;
} else { } else {
if ($_SESSION['config']['debug'] == 'true') { if ($_SESSION['config']['debug'] == 'true') {
echo $queryString; echo $queryString;
var_export($parameters); var_export($parameters);
}
throw $PDOException;
} }
throw $PDOException;
} }
} }
return $this->stmt; return $this->stmt;
} }
public function limit_select($start, $count, $select_expr, $table_refs, $where_def='1=1', $other_clauses='', $select_opts='') public function limit_select($start, $count, $select_expr, $table_refs, $where_def='1=1', $other_clauses='', $select_opts='')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment