<?php
class Product extends RedBean_SimpleModel {
public function __get( $prop ) {
// If the prop we're looking for is the pictures list
if ($prop == "ownPictureList") {
/**
* Automatically adds ->with(' ORDER BY position ') if you haven't specified with()
*
* This means it'll actually turn $product->ownPictureList into $product->with(' ORDER BY position ')->ownPictureList
* But won't modify something like $product->with(' LIMIT 1, 20 ')->ownProductList
* You'd have to modify the following code to check for the ORDER BY clause and add it accordingly if that's what you need.
*/
if (empty($this->bean->withSql)) {
$this->bean->with(' ORDER BY position ');
}
}
// What this function was first meant to return, don't forget it :)
return $this->bean->$prop;
}
}
?>