Skip to content

Commit

Permalink
fixed problem with select in transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
splitbrain committed May 8, 2013
1 parent c137e95 commit b122d12
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 3 deletions.
7 changes: 7 additions & 0 deletions classes/adapter.php
Expand Up @@ -393,6 +393,13 @@ public abstract function quote_string($string);
*/
public abstract function escape_string($str);

/**
* Close the result set and it's cursors
*
* @param $res
*/
public abstract function res_close($res);

/**
* Returns a complete result set as array
*/
Expand Down
12 changes: 11 additions & 1 deletion classes/adapter_null.php
Expand Up @@ -61,7 +61,17 @@ public function escape_string($str) {
return $str;
}

/**
/**
* Close the result set and it's cursors
*
* @param $res
* @return bool
*/
public function res_close($res) {
return true;
}

/**
* Returns a complete result set as array
*/
public function res2arr($res, $assoc = true) {
Expand Down
12 changes: 11 additions & 1 deletion classes/adapter_pdosqlite.php
Expand Up @@ -89,13 +89,23 @@ public function executeQuery($sql) {

if(!$res) {
$err = $this->db->errorInfo();
msg($err[2].':<br /><pre>'.hsc($sql).'</pre>', -1);
msg($err[0].' '.$err[1].' '.$err[2].':<br /><pre>'.hsc($sql).'</pre>', -1);
return false;
}

return $res;
}

/**
* Close the result set and it's cursors
*
* @param PDOStatement $res
* @return bool
*/
public function res_close($res) {
return $res->closeCursor();
}

/**
* Returns a complete result set as array
*/
Expand Down
10 changes: 10 additions & 0 deletions classes/adapter_sqlite2.php
Expand Up @@ -78,6 +78,16 @@ public function executeQuery($sql) {
return $res;
}

/**
* Close the result set and it's cursors
*
* @param $res
* @return bool
*/
public function res_close($res) {
return true; //seems not to be needed in sqlite2?
}

/**
* Returns a complete result set as array
*/
Expand Down
13 changes: 13 additions & 0 deletions helper.php
Expand Up @@ -448,6 +448,19 @@ public function escape_string($str) {
return $this->adapter->escape_string($str);
}

/**
* Closes the result set (and it's cursors)
*
* If you're doing SELECT queries inside a TRANSACTION, be sure to call this
* function on all your results sets, before COMMITing the transaction.
*
* @param $res
* @return bool
*/
public function res_close($res){
return $this->adapter->res_close($res);
}

/**
* Returns a complete result set as array
*/
Expand Down
2 changes: 1 addition & 1 deletion plugin.info.txt
@@ -1,7 +1,7 @@
base sqlite
author Andreas Gohr
email gohr@cosmocode.de
date 2013-05-06
date 2013-05-08
name sqlite plugin
desc A helper plugin to easily access a SQLite database
url http://www.dokuwiki.org/plugin:sqlite

0 comments on commit b122d12

Please sign in to comment.