summaryrefslogtreecommitdiff
path: root/framework/Data/ActiveRecord/Vendor/TDbMetaData.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Data/ActiveRecord/Vendor/TDbMetaData.php')
-rw-r--r--framework/Data/ActiveRecord/Vendor/TDbMetaData.php38
1 files changed, 30 insertions, 8 deletions
diff --git a/framework/Data/ActiveRecord/Vendor/TDbMetaData.php b/framework/Data/ActiveRecord/Vendor/TDbMetaData.php
index 38a82aef..3a959ba4 100644
--- a/framework/Data/ActiveRecord/Vendor/TDbMetaData.php
+++ b/framework/Data/ActiveRecord/Vendor/TDbMetaData.php
@@ -20,8 +20,7 @@
* @version $Id$
* @package System.Data.ActiveRecord.Vendor
* @since 3.1
- */
-
+ */
abstract class TDbMetaData extends TComponent
{
private $_primaryKeys=array();
@@ -91,6 +90,11 @@ abstract class TDbMetaData extends TComponent
return $this->_columns[$name];
}
+ public function getColumnNames()
+ {
+ return array_keys($this->_columns);
+ }
+
/**
* Post process the rows after returning from a 1 row query.
* @param mixed row data, may be null.
@@ -187,7 +191,7 @@ abstract class TDbMetaData extends TComponent
foreach($keys as $i => $key)
{
$value = isset($values[$i]) ? $values[$i] : $values[$key];
- $command->bindValue(':'.$key, $value);
+ $this->bindValue($command, ':'.$key, $value);
}
$command->prepare();
}
@@ -249,7 +253,7 @@ abstract class TDbMetaData extends TComponent
/**
* Gets a comma delimited string of name parameters for update.
-x * @param array name value pairs of columns for update.
+ * @param array name value pairs of columns for update.
* @return string update named parameter string.
*/
protected function getUpdateBindings($columns)
@@ -294,19 +298,27 @@ x * @param array name value pairs of columns for update.
if($criteria->getIsNamedParameters())
{
foreach($criteria->getParameters() as $name=>$value)
- $command->bindValue($name,$value);
+ $this->bindValue($command, $name, $value);
}
else
{
$index=1;
foreach($criteria->getParameters() as $value)
- $command->bindValue($index++,$value);
+ $this->bindValue($command, $index++,$value);
}
}
$command->prepare();
return $command;
}
+ protected function bindValue($command, $name, $value)
+ {
+ if(is_bool($value))
+ $command->bindValue($name,$value, PDO::PARAM_BOOL);
+ else
+ $command->bindValue($name,$value);
+ }
+
/**
* Bind parameter values.
*/
@@ -316,9 +328,9 @@ x * @param array name value pairs of columns for update.
foreach($parameters as $key=>$value)
{
if(is_string($key))
- $command->bindValue($key,$value);
+ $this->bindValue($command,$key,$value);
else
- $command->bindValue($index++,$value);
+ $this->bindValue($command, $index++,$value);
}
$command->prepare();
}
@@ -345,5 +357,15 @@ x * @param array name value pairs of columns for update.
return implode(', ', $fields);
}
+ /**
+ * @param string ordering column name
+ * @param string ordering direction
+ * @return string DESC or ASC
+ */
+ protected function getOrdering($by, $direction)
+ {
+ $dir = strtolower($direction) == 'desc' ? 'DESC' : 'ASC';
+ return $this->getColumn($by)->getName(). ' '.$dir;
+ }
}
?> \ No newline at end of file