summaryrefslogtreecommitdiff
path: root/framework/Data/ActiveRecord/Vendor/TPgsqlMetaData.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Data/ActiveRecord/Vendor/TPgsqlMetaData.php')
-rw-r--r--framework/Data/ActiveRecord/Vendor/TPgsqlMetaData.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/framework/Data/ActiveRecord/Vendor/TPgsqlMetaData.php b/framework/Data/ActiveRecord/Vendor/TPgsqlMetaData.php
new file mode 100644
index 00000000..7f4f1f82
--- /dev/null
+++ b/framework/Data/ActiveRecord/Vendor/TPgsqlMetaData.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * TPgsqlMetaData class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Data.ActiveRecord.Vendor
+ */
+
+Prado::using('System.Data.ActiveRecord.Vendor.TDbMetaDataCommon');
+
+/**
+ * TPgsqlMetaData class.
+ *
+ * Command builder for Postgres database
+ *
+ * @author Wei Zhuo <weizho[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Data.ActiveRecord.Vendor
+ * @since 3.1
+ */
+class TPgsqlMetaData 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)
+ $sql .= ' LIMIT '.$limit;
+ if(($offset = $criteria->getOffset())!==null)
+ $sql .= ' OFFSET '.$offset;
+ return strlen($sql) > 0 ? ' WHERE '.$sql : '';
+ }
+}
+?> \ No newline at end of file