svn: /pear/packages/HTTP_Session2/trunk/HTTP/Session2/Container/ MDB2.php
| From: | Till Klampaeckel | Date: | Fri, 03 Sep 2010 14:20:44 +0000 |
| Subject: | svn: /pear/packages/HTTP_Session2/trunk/HTTP/Session2/Container/ MDB2.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-60236@lists.php.net to get a copy of this message | ||
till Fri, 03 Sep 2010 14:20:44 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=303027
Log:
* #17647: collect some info on the last query
* expose it all via public method
Bug: http://pear.php.net/bugs/17647 (unknown)
Changed paths:
U pear/packages/HTTP_Session2/trunk/HTTP/Session2/Container/MDB2.php
Modified: pear/packages/HTTP_Session2/trunk/HTTP/Session2/Container/MDB2.php
===================================================================
--- pear/packages/HTTP_Session2/trunk/HTTP/Session2/Container/MDB2.php 2010-09-03 14:20:32 UTC (rev
303026)
+++ pear/packages/HTTP_Session2/trunk/HTTP/Session2/Container/MDB2.php 2010-09-03 14:20:44 UTC (rev
303027)
@@ -69,6 +69,11 @@
protected $crc = false;
/**
+ * @var array $lastDbQuery
+ */
+ protected $lastDbQuery = array('affected_rows' => null, 'query' =>
null);
+
+ /**
* Constrtuctor method
*
* $options is an array with the options.<br>
@@ -244,11 +249,15 @@
$time);
}
}
- $result = $this->db->query($query);
+ $result = $this->db->exec($query);
if (MDB2::isError($result)) {
throw new HTTP_Session2_Exception($result->getUserInfo(),
$result->getCode());
}
+
+ $this->lastDbQuery['affected_rows'] = $result;
+ $this->lastDbQuery['query'] = $query;
+
return true;
}
@@ -266,11 +275,15 @@
$this->options['table'],
$this->db->quote(md5($id)));
- $result = $this->db->query($query);
+ $result = $this->db->exec($query);
if (MDB2::isError($result)) {
throw new HTTP_Session2_Exception ($result->getMessage(),
$result->getCode());
}
+
+ $this->lastDbQuery['affected_rows'] = $result;
+ $this->lastDbQuery['query'] = $query;
+
return true;
}
@@ -291,12 +304,15 @@
$this->options['table'],
$this->getTime());
- $result = $this->db->query($query);
+ $result = $this->db->exec($query);
if (MDB2::isError($result)) {
throw new HTTP_Session2_Exception($result->getMessage(),
$result->getCode());
}
+ $this->lastDbQuery['affected_rows'] = $result;
+ $this->lastDbQuery['query'] = $query;
+
if ($this->options['autooptimize']) {
$this->db->loadModule('Manager');
$result = $this->db->vacuum($this->options['table']);
@@ -349,12 +365,25 @@
$query .= " AND src.id = " . $this->db->quote(md5($id),
'text');
}
- $result = $this->db->query($query);
+ $result = $this->db->exec($query);
if (MDB2::isError($result)) {
throw new HTTP_Session2_Exception($result->getDebugInfo(),
$result->getCode());
}
+ $this->lastDbQuery['affected_rows'] = $result;
+ $this->lastDbQuery['query'] = $query;
+
return true;
}
+
+ /**
+ * For debugging, testing.
+ *
+ * @return array
+ */
+ public function getLastDbQuery()
+ {
+ return $this->lastDbQuery;
+ }
}