commit d272e241ddc99786ea351fb1bf97c90e06c3a5f8
parent 6734aa41bd59a6bfb16a2326f0852e4dbcfb3224
Author: dankert <devnull@localhost>
Date: Fri, 15 Jan 2010 19:39:43 +0100
Vorbereitungen für Prepared Statements
Diffstat:
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/db/mysqli.class.php b/db/mysqli.class.php
@@ -46,7 +46,8 @@ class DB_mysqli
* @var Resource
*/
var $stmt;
-
+
+ var $prepared = false;
var $params = array();
@@ -109,7 +110,7 @@ class DB_mysqli
function query($query)
{
- if ( is_object($this->stmt) )
+ if ( $this->prepared )
{
foreach($this->params as $name => $data)
{
@@ -128,8 +129,10 @@ class DB_mysqli
$ar[] = &$data['value'];
}
- call_user_func_array(array($this->stmt, 'bind_param'),$ar);
-
+ call_user_func_array('bind_param',array($this->stmt,$ar));
+ $this->stmt->execute();
+ $this->stmt->bind_result( $a, $b );
+ return $this->stmt;
}
$result = mysqli_query($this->connection,$query);
@@ -182,7 +185,7 @@ class DB_mysqli
}
$this->stmt = mysqli_prepare($this->connection,$query);
-
+ $this->prepared = true;
}
function bind( $param,$value )
@@ -217,6 +220,15 @@ class DB_mysqli
mysqli_query($this->connection,'ROLLBACK');
}
+
+ /**
+ * Setzt die letzte Abfrage zurueck.
+ */
+ function clear()
+ {
+ $this->prepared = false;
+ $this->params = array();
+ }
}