summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
Diffstat (limited to 'framework')
-rw-r--r--framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php1
-rw-r--r--framework/Data/ActiveRecord/TActiveRecordManager.php11
-rw-r--r--framework/Data/ActiveRecord/Vendor/TDbMetaData.php11
3 files changed, 19 insertions, 4 deletions
diff --git a/framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php b/framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php
index 4e96a19d..266d4346 100644
--- a/framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php
+++ b/framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php
@@ -73,7 +73,6 @@ abstract class TScaffoldBase extends TTemplateControl
*/
protected function getRecordPkValues($record)
{
- $pk = array();
foreach($this->getTableMetaData()->getColumns() as $name=>$column)
{
if($column->getIsPrimaryKey())
diff --git a/framework/Data/ActiveRecord/TActiveRecordManager.php b/framework/Data/ActiveRecord/TActiveRecordManager.php
index f7568b51..0179479e 100644
--- a/framework/Data/ActiveRecord/TActiveRecordManager.php
+++ b/framework/Data/ActiveRecord/TActiveRecordManager.php
@@ -121,6 +121,17 @@ class TActiveRecordManager extends TComponent
}
/**
+ * @param string|TActiveRecord active record class name or instance
+ * @return TDbMetaData record specific meta data
+ */
+ public function getMetaData($record)
+ {
+ if(is_string($record))
+ $record = TActiveRecord::finder($record);
+ return $this->getRecordGateway()->getMetaData($record);
+ }
+
+ /**
* @return TActiveRecordGateway default record gateway.
*/
protected function createRecordGateway()
diff --git a/framework/Data/ActiveRecord/Vendor/TDbMetaData.php b/framework/Data/ActiveRecord/Vendor/TDbMetaData.php
index a3a13120..37537548 100644
--- a/framework/Data/ActiveRecord/Vendor/TDbMetaData.php
+++ b/framework/Data/ActiveRecord/Vendor/TDbMetaData.php
@@ -25,7 +25,12 @@ abstract class TDbMetaData extends TComponent
{
private $_primaryKeys=array();
private $_foreignKeys=array();
- private $_columns=array();
+
+ /**
+ * @var TMap column meta data.
+ */
+ private $_columns;
+
private $_table;
private $_isView=false;
@@ -39,7 +44,7 @@ abstract class TDbMetaData extends TComponent
public function __construct($table, $cols, $pk, $fk=array(),$view=false)
{
$this->_table=$table;
- $this->_columns=$cols;
+ $this->_columns=new TMap($cols);
$this->_primaryKeys=$pk;
$this->_foreignKeys=$fk;
$this->_isView=$view;
@@ -92,7 +97,7 @@ abstract class TDbMetaData extends TComponent
public function getColumnNames()
{
- return array_keys($this->_columns);
+ return $this->_columns->getKeys();
}
/**