summaryrefslogtreecommitdiff
path: root/framework/Data/Common/Sqlite
diff options
context:
space:
mode:
authorwei <>2007-05-03 00:48:04 +0000
committerwei <>2007-05-03 00:48:04 +0000
commit1ae09931b2572d9c3067c99f841a60cb3330b3f3 (patch)
tree0b263b594bfa9c2bf5b37d2d565b4583f796bf2c /framework/Data/Common/Sqlite
parent24bdc94145c11744f624149a0dbdd10e3d5ca4cd (diff)
Update active relations docs
Diffstat (limited to 'framework/Data/Common/Sqlite')
-rw-r--r--framework/Data/Common/Sqlite/TSqliteCommandBuilder.php48
-rw-r--r--framework/Data/Common/Sqlite/TSqliteMetaData.php2
-rw-r--r--framework/Data/Common/Sqlite/TSqliteTableInfo.php9
3 files changed, 58 insertions, 1 deletions
diff --git a/framework/Data/Common/Sqlite/TSqliteCommandBuilder.php b/framework/Data/Common/Sqlite/TSqliteCommandBuilder.php
new file mode 100644
index 00000000..9f1253c9
--- /dev/null
+++ b/framework/Data/Common/Sqlite/TSqliteCommandBuilder.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * TSqliteCommandBuilder class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2007 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id: TDbCommandBuilder.php 1863 2007-04-12 12:43:49Z wei $
+ * @package System.Data.Common
+ */
+
+Prado::using('System.Data.Common.TDbCommandBuilder');
+
+/**
+ * TSqliteCommandBuilder provides specifics methods to create limit/offset query commands
+ * for Sqlite database.
+ *
+ * @author Wei Zhuo <weizho[at]gmail[dot]com>
+ * @version $Id: TDbCommandBuilder.php 1863 2007-04-12 12:43:49Z wei $
+ * @package System.Data.Common
+ * @since 3.1
+ */
+class TSqliteCommandBuilder extends TDbCommandBuilder
+{
+ /**
+ * Alters the sql to apply $limit and $offset.
+ * @param string SQL query string.
+ * @param integer maximum number of rows, -1 to ignore limit.
+ * @param integer row offset, -1 to ignore offset.
+ * @return string SQL with limit and offset.
+ */
+ public function applyLimitOffset($sql, $limit=-1, $offset=-1)
+ {
+ $limit = $limit!==null ? intval($limit) : -1;
+ $offset = $offset!==null ? intval($offset) : -1;
+ if($limit > 0 || $offset > 0)
+ {
+ $limitStr = ' LIMIT '.$limit;
+ $offsetStr = $offset >= 0 ? ' OFFSET '.$offset : '';
+ return $sql.$limitStr.$offsetStr;
+ }
+ else
+ return $sql;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/framework/Data/Common/Sqlite/TSqliteMetaData.php b/framework/Data/Common/Sqlite/TSqliteMetaData.php
index f9b49488..6c6ff232 100644
--- a/framework/Data/Common/Sqlite/TSqliteMetaData.php
+++ b/framework/Data/Common/Sqlite/TSqliteMetaData.php
@@ -49,7 +49,7 @@ class TSqliteMetaData extends TDbMetaData
if($column->getIsPrimaryKey())
$primary[] = $col['name'];
}
- $info['TableName'] = $tableName;
+ $info['TableName'] = $table;
if($this->getIsView($tableName))
$info['IsView'] = true;
if(count($columns)===0)
diff --git a/framework/Data/Common/Sqlite/TSqliteTableInfo.php b/framework/Data/Common/Sqlite/TSqliteTableInfo.php
index 1581c3cc..e0bcb484 100644
--- a/framework/Data/Common/Sqlite/TSqliteTableInfo.php
+++ b/framework/Data/Common/Sqlite/TSqliteTableInfo.php
@@ -26,6 +26,15 @@ Prado::using('System.Data.Common.Sqlite.TSqliteTableColumn');
*/
class TSqliteTableInfo extends TDbTableInfo
{
+ /**
+ * @param TDbConnection database connection.
+ * @return TDbCommandBuilder new command builder
+ */
+ public function createCommandBuilder($connection)
+ {
+ Prado::using('System.Data.Common.Sqlite.TSqliteCommandBuilder');
+ return new TSqliteCommandBuilder($connection,$this);
+ }
}
?> \ No newline at end of file