summaryrefslogtreecommitdiff
path: root/framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php
diff options
context:
space:
mode:
authorwei <>2006-11-26 22:15:58 +0000
committerwei <>2006-11-26 22:15:58 +0000
commita8b3ebe8f62c3888b216d827c1c5dcba8a47d4e1 (patch)
tree5eef79dbc5e2f506047fa463cb427a40a7bd8441 /framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php
parent6773dfe453682d2b39a26fbabef8e706bf6bb412 (diff)
Adding active record implementation.
Diffstat (limited to 'framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php')
-rw-r--r--framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php b/framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php
new file mode 100644
index 00000000..7902146d
--- /dev/null
+++ b/framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * TMysqlMetaData class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Data.ActiveRecord.Vendor
+ */
+
+Prado::using('System.Data.ActiveRecord.Vendor.TDbMetaDataCommon');
+
+/**
+ * TMysqlMetaData specialized command builder for Mysql database.
+ *
+ * @author Wei Zhuo <weizho[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Data.ActiveRecord.Vendor
+ * @since 3.1
+ */
+class TMysqlMetaData extends TDbMetaDataCommon
+{
+ /**
+ * Build the SQL search string from the criteria object for Postgress database.
+ * @param TActiveRecordCriteria search criteria.
+ * @return string SQL search.
+ */
+ protected function getSqlFromCriteria(TActiveRecordCriteria $criteria)
+ {
+ $sql = '';
+ if(($condition = $criteria->getCondition())!==null)
+ $sql .= $condition;
+ $orders=array();
+ foreach($criteria->getOrdersBy() as $by=>$ordering)
+ $orders[] = $by.' '.$ordering;
+ if(count($orders) > 0)
+ $sql .= ' ORDER BY '.implode(', ', $orders);
+ if(($limit = $criteria->getLimit())!==null)
+ {
+ $offset = $criteria->getOffset();
+ $offset = $offset===null?0:$offset;
+ $sql .= ' LIMIT '.$offset.', '.$limit;
+ }
+ return strlen($sql) > 0 ? ' WHERE '.$sql : '';
+ }
+}
+
+?> \ No newline at end of file