Permalink
Browse files

Added support for event listeners for profiling, logging etc.

  • Loading branch information...
1 parent 1f0dd9c commit 3c5714ed3ea672bed95e2a647357923287b04f18 @kallaspriit committed May 12, 2012
@@ -33,10 +33,10 @@
/**
* MySQL database adapter
*
- * @id $Id: MysqlDbAdapter.php 57 2011-02-13 12:36:08Z kallaspriit $
- * @author $Author: kallaspriit $
- * @version $Revision: 57 $
- * @modified $Date: 2011-02-13 14:36:08 +0200 (Sun, 13 Feb 2011) $
+ * @id $Id: MysqlDbAdapter.php 349638 2012-05-09 05:50:24Z priitk $
+ * @author $Author: priitk $
+ * @version $Revision: 349638 $
+ * @modified $Date: 2012-05-09 08:50:24 +0300 (K, 09 mai 2012) $
* @package Lightspeed
* @subpackage Model
*/
@@ -360,17 +360,16 @@ public static function count(
$query,
array $bind = array()
) {
- $statement = $connection->prepare($query);
-
- foreach ($bind as $key => $value) {
- $statement->bindValue(':'.$key, $value);
- }
-
- $statement->execute();
-
+ $statement = null;
+
+ PdoModel::execute($query, $bind, $statement, $connection);
+
$rowsQuery = 'SELECT FOUND_ROWS() AS `rows`';
- $rowsStatement = $connection->prepare($rowsQuery);
- $rowsStatement->execute();
+
+ $rowsStatement = null;
+
+ PdoModel::execute($rowsQuery, array(), $rowsStatement, $connection);
+
$rowsData = $rowsStatement->fetch(PDO::FETCH_NUM);
return $rowsData[0];
@@ -405,30 +404,10 @@ public static function getItems(
$query = 'SELECT SQL_CALC_FOUND_ROWS '.
substr($query, 7).' LIMIT '
.(int)$offset.', '.(int)$limit;
-
- $statement = $connection->prepare($query);
-
- if ($statement === false) {
- //@codeCoverageIgnoreStart
- throw new Exception(
- 'Preparing find query "'.$query.'" failed'
- );
- //@codeCoverageIgnoreEnd
- }
-
- if (!empty($bind)) {
- foreach ($bind as $column => $value) {
- $statement->bindValue(':'.$column, $value);
- }
- }
-
- if ($statement->execute() === false) {
- //@codeCoverageIgnoreStart
- throw new Exception(
- 'Executing statement for find query "'.$query.'" failed'
- );
- //@codeCoverageIgnoreEnd
- }
+
+ $statement = null;
+
+ PdoModel::execute($query, $bind, $statement, $connection);
return $statement->fetchAll(PDO::FETCH_ASSOC);
}
@@ -33,10 +33,10 @@
/**
* SQLite database adapter
*
- * @id $Id: MysqlDbAdapter.php 53 2011-02-09 20:21:33Z kallaspriit $
- * @author $Author: kallaspriit $
- * @version $Revision: 53 $
- * @modified $Date: 2011-02-09 22:21:33 +0200 (Wed, 09 Feb 2011) $
+ * @id $Id: SqliteDbAdapter.php 346560 2012-04-12 08:28:33Z priitk $
+ * @author $Author: priitk $
+ * @version $Revision: 346560 $
+ * @modified $Date: 2012-04-12 11:28:33 +0300 (N, 12 apr 2012) $
* @package Lightspeed
* @subpackage Model
*/
@@ -33,10 +33,10 @@
* Adapters need to implement given methods used by PdoModel so the PdoModel
* can be used to communicate with different database vendors.
*
- * @id $Id: DbAdapter.php 65 2011-03-01 16:01:06Z kallaspriit $
- * @author $Author: kallaspriit $
- * @version $Revision: 65 $
- * @modified $Date: 2011-03-01 18:01:06 +0200 (Tue, 01 Mar 2011) $
+ * @id $Id: DbAdapter.php 346560 2012-04-12 08:28:33Z priitk $
+ * @author $Author: priitk $
+ * @version $Revision: 346560 $
+ * @modified $Date: 2012-04-12 11:28:33 +0300 (N, 12 apr 2012) $
* @package Lightspeed
* @subpackage Model
*/
Oops, something went wrong.

0 comments on commit 3c5714e

Please sign in to comment.