summaryrefslogtreecommitdiff
path: root/framework/Data/ActiveRecord/TActiveRecord.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Data/ActiveRecord/TActiveRecord.php')
-rw-r--r--framework/Data/ActiveRecord/TActiveRecord.php33
1 files changed, 31 insertions, 2 deletions
diff --git a/framework/Data/ActiveRecord/TActiveRecord.php b/framework/Data/ActiveRecord/TActiveRecord.php
index 68d63a23..d3e25dcf 100644
--- a/framework/Data/ActiveRecord/TActiveRecord.php
+++ b/framework/Data/ActiveRecord/TActiveRecord.php
@@ -38,7 +38,7 @@ Prado::using('System.Data.ActiveRecord.TActiveRecordCriteria');
* public $username; //corresponds to the fieldname in the table
* public $email;
*
- * private static final $_tablename='users'; //optional table name.
+ * public static final $_tablename='users'; //optional table name.
*
* //returns active record finder instance
* public static function finder()
@@ -332,7 +332,7 @@ abstract class TActiveRecord extends TComponent
*/
public function findByPk($keys)
{
- if(func_num_args() > 1 && !is_array($keys))
+ if(func_num_args() > 1)
$keys = func_get_args();
$gateway = $this->getRecordManager()->getRecordGateway();
$data = $gateway->findRecordByPK($this,$keys);
@@ -340,6 +340,35 @@ abstract class TActiveRecord extends TComponent
}
/**
+ * Find multiple records matching a list of primary or composite keys.
+ *
+ * For scalar primary keys:
+ * <code>
+ * $finder->findAllByPk($key1, $key2, ...);
+ * $finder->findAllByPk(array($key1, $key2, ...));
+ * </code>
+ *
+ * For composite keys:
+ * <code>
+ * $finder->findAllByPk(array($key1, $key2), array($key3, $key4), ...);
+ * $finder->findAllByPk(array(array($key1, $key2), array($key3, $key4), ...));
+ * </code>
+ * @param mixed primary keys
+ * @return array matching ActiveRecords
+ */
+ public function findAllByPks($keys)
+ {
+ if(func_num_args() > 1)
+ $keys = func_get_args();
+ $gateway = $this->getRecordManager()->getRecordGateway();
+ $results = array();
+ $class = get_class($this);
+ foreach($gateway->findRecordsByPks($this,(array)$keys) as $data)
+ $results[] = $this->populateObject($class,$data);
+ return $results;
+ }
+
+ /**
* Find records using full SQL, returns corresponding record object.
* @param string select SQL
* @param array $parameters