Skip to content

Commit 8846b96

Browse files
committed
Attempt to fix some issues with prepaired explain queries
1 parent 07d27ba commit 8846b96

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

init.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@
1212
require_once('config.php');
1313
require_once('util.php');
1414
require_once('libs/Database/Database.php');
15-
Database::connect(null, $reviewhost['user'], $reviewhost['password'], null, null, 'pdo', array('dsn' => $reviewhost['dsn']), 'review');
15+
16+
$options = array('dsn' => $reviewhost['dsn'],
17+
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true
18+
);
19+
20+
Database::connect(null, $reviewhost['user'], $reviewhost['password'], null, null, 'pdo', $options, 'review');
1621

1722
// Needed for SqlParser
18-
$dbh = new PDO($reviewhost['dsn'], $reviewhost['user'], $reviewhost['password']);
23+
$dbh = new PDO($reviewhost['dsn'], $reviewhost['user'], $reviewhost['password'], $options);
1924

2025
require_once('libs/sqlquery/SqlParser.php');
2126
require_once('classes/QueryRewrite.php');

libs/Database/Database/Query/pdo.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,15 @@ public function execute() {
6666
// working on prepared statements that return multiple result sets
6767
// combined with multiple concurrent statement handles. See the
6868
// comments on the PDOStatement::closeCursor() manual page.
69-
$this->sh = $this->dbh->prepare($this->last_query);
70-
$this->sh->execute($nargs);
69+
70+
// Skip preparing the query if there are no args in the query.
71+
if ($nargn == 0) {
72+
$this->sh = $this->dbh->query($this->last_query);
73+
}
74+
else {
75+
$this->sh = $this->dbh->prepare($this->last_query);
76+
$this->sh->execute($nargs);
77+
}
7178
} catch(PDOException $e) {
7279
$this->last_exception = $e;
7380
$this->db->error('SQL Error:');

0 commit comments

Comments
 (0)