[pLog-svn] r2192 - in plog/trunk/class: dao database/pdb
database/pdb/drivers
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Fri Jun 10 12:21:20 GMT 2005
Author: oscar
Date: 2005-06-10 12:21:19 +0000 (Fri, 10 Jun 2005)
New Revision: 2192
Modified:
plog/trunk/class/dao/model.class.php
plog/trunk/class/database/pdb/drivers/pdbdriverbase.class.php
plog/trunk/class/database/pdb/drivers/pdbmysqldriver.class.php
plog/trunk/class/database/pdb/pdb.class.php
Log:
moved the pagination stuff to the database-dependent layer, or else this would
never work if we move to other rdbms such as pgsql.
Modified: plog/trunk/class/dao/model.class.php
===================================================================
--- plog/trunk/class/dao/model.class.php 2005-06-10 12:14:28 UTC (rev 2191)
+++ plog/trunk/class/dao/model.class.php 2005-06-10 12:21:19 UTC (rev 2192)
@@ -103,15 +103,8 @@
{
// $this->log->info("executing $query");
$this->_initializeDb();
-
- // if paging is enabled...
- if( $page > DEFAULT_PAGING_ENABLED ) {
- $start = (($page - 1) * $itemsPerPage);
- $limits = " LIMIT $start, $itemsPerPage";
- $query .= " $limits";
- }
- $result = $this->_db->Execute( $query );
+ $result = $this->_db->Execute( $query, $page, $itemsPerPage );
// if the query generated an error, write a message to the sql error log file
if( !$result ) {
Modified: plog/trunk/class/database/pdb/drivers/pdbdriverbase.class.php
===================================================================
--- plog/trunk/class/database/pdb/drivers/pdbdriverbase.class.php 2005-06-10 12:14:28 UTC (rev 2191)
+++ plog/trunk/class/database/pdb/drivers/pdbdriverbase.class.php 2005-06-10 12:21:19 UTC (rev 2192)
@@ -1,6 +1,16 @@
<?php
include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
+
+ /**
+ * how many items per page by default, when paging is enabled
+ */
+ define( "DEFAULT_ITEMS_PER_PAGE", 15 );
+
+ /**
+ * whether we're going to use paging or not.
+ */
+ define( "DEFAULT_PAGING_ENABLED", -1 );
class PDbDriverBase extends Object
{
@@ -28,7 +38,7 @@
// to be implemented by child classes
}
- function Execute( $query )
+ function Execute( $query, $page = DEFAULT_PAGING_ENABLED, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
{
// to be implemented by child classes
}
Modified: plog/trunk/class/database/pdb/drivers/pdbmysqldriver.class.php
===================================================================
--- plog/trunk/class/database/pdb/drivers/pdbmysqldriver.class.php 2005-06-10 12:14:28 UTC (rev 2191)
+++ plog/trunk/class/database/pdb/drivers/pdbmysqldriver.class.php 2005-06-10 12:21:19 UTC (rev 2192)
@@ -14,8 +14,14 @@
$this->PDbDriverBase();
}
- function Execute( $query )
+ function Execute( $query, $page = DEFAULT_PAGING_ENABLED, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
{
+ if( $page > DEFAULT_PAGING_ENABLED ) {
+ $start = (($page - 1) * $itemsPerPage);
+ $limits = " LIMIT $start, $itemsPerPage";
+ $query .= " $limits";
+ }
+
// execute the query and see whether it was incorrect
$this->_debugQuery( $query );
Modified: plog/trunk/class/database/pdb/pdb.class.php
===================================================================
--- plog/trunk/class/database/pdb/pdb.class.php 2005-06-10 12:14:28 UTC (rev 2191)
+++ plog/trunk/class/database/pdb/pdb.class.php 2005-06-10 12:21:19 UTC (rev 2192)
@@ -3,6 +3,16 @@
include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
define( "PDB_DRIVER_FOLDER", PLOG_CLASS_PATH."class/database/pdb/drivers/" );
+
+ /**
+ * how many items per page by default, when paging is enabled
+ */
+ define( "DEFAULT_ITEMS_PER_PAGE", 15 );
+
+ /**
+ * whether we're going to use paging or not.
+ */
+ define( "DEFAULT_PAGING_ENABLED", -1 );
/**
* PDb
More information about the pLog-svn
mailing list