Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I tend to work at the DbTable like you do. I've found it effective when I need to query multiple tables in a single action to create another layer of model above the dbTable. Similar to a service or domain layer. This way I only have to call a single model but I still have the functionality I need. <br /></p> <p>Here is a simple example that may eventually interact with 5 DbTable classes and most likely a couple of Row classes as well:</p> <pre><code>&lt;?php class Application_Model_TrackInfo { protected $_track; protected $_bidLocation; protected $_weekend; protected $_shift; protected $_station; public function __construct() { //assign DbTable models to properties for convience $this-&gt;_track = new Application_Model_DbTable_Track(); } /** * * @param type $trackId * @return type object */ public function getByTrackId($trackId) { $trackData = $this-&gt;_track-&gt;fetchRow($trackId); //getAllInfo() Application_Model_Row_TRack $result = $trackData-&gt;getAllInfo(); //returns std object reflecting data from 3 DbTable classes return $result; } /** *Get Station from trackid through bidlocationid * * @param type $trackId * @return type object */ public function getStation($trackId){ $data = $this-&gt;_track-&gt;fetchRow($trackId); //This a Application_Model_Row_Track method $result= $data-&gt;getStationFromBidLocation(); return $result; } } </code></pre> <p>I hope this helps.<br /></p> <p><strong>[EDIT]</strong> Since I wrote this answer I have learned the benefits of Domain Models and Data Mappers. Wow what a difference in my app. Not a magic bullet, but a huge improvement.<br /> Thanks to<br /> Alejandro Gervasio over at <a href="http://phpmaster.com/author/agervasio/" rel="nofollow">PHPMaster.com</a><br /> Rob Allen at <a href="http://akrabat.com/" rel="nofollow">Akrabat.com</a><br /> and <br /> Pádraic Brady at <a href="http://www.survivethedeepend.com/" rel="nofollow">Surviving The Deepend</a></p> <p>for all their help in understanding this pattern.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload