Permalink
Browse files

Merge pull request #90 from frenchcomp/patch-2

Update library/Centurion/Db/Table/Row/Abstract.php
  • Loading branch information...
lchenay committed Aug 1, 2012
2 parents 1370fb5 + 4c38424 commit fb546c6945c13944cd25d722b77f7446bfb7b938
Showing with 15 additions and 1 deletion.
  1. +15 −1 library/Centurion/Db/Table/Row/Abstract.php
@@ -238,10 +238,24 @@ public function __get($columnName)
$data['refforeign'] = substr($data['columns']['foreign'], 0, -3);
$data['reflocal'] = substr($data['columns']['local'], 0, -3);
}
+
+ //Support of ordered many to many to avoid regression
+ $intersectionTable = $data['intersectionTable'];
+ if (is_string($intersectionTable)) {
+ //this operation is also performed in the next call to findManyToManyRowset()
+ $intersectionTable = $this->_getTableFromString($intersectionTable);
+ }
+
+ if (in_array('order', $intersectionTable->info('cols'))) {
+ // Use adapter from intersection table to ensure correct query construction
+ $interName = $intersectionTable->info(Centurion_Db_Table::NAME);
+ //findManyToManyRowset() not perform this because we send a select object to the method
+ $select->order($interName.'.order asc');
+ }
$this->_children[$columnName]
= $this->findManyToManyRowset($data['refTableClass'],
- $data['intersectionTable'],
+ $intersectionTable,
$data['reflocal'],
$data['refforeign'],
$select, $refForeignCond);

0 comments on commit fb546c6

Please sign in to comment.