Multiple Join's

Adam Moore
  • Adam Moore

    Adam Moore - 2007-10-02

    I have been making large changes to the Software Section of my OpenIT install.  Here are the changes.

    2 new tables: SoftwareTitle, SoftwareVersion
    Removed: SoftwareTypes

    Now their will be 2 lookups.  SoftwareTitle and SoftwareVersion.
    When I want to list SoftwareVersion in the lookups I need to do 2 joins.  Vendors and SoftwareTitle

    Any idea on how to do those two joins in the SoftwareVersion.php file? (This file was SoftwareTypes.php)



    • Adam Moore

      Adam Moore - 2007-10-03

      After some trial and error, and some awesome debugging features built in, I found my solution.  It involved some major changes to how joins are handled in the lookup list and softwareVersion.php file I created. Here are the bits.

      I have added the option for $join to be an array in the lookup classes such as inc/classes/SoftwareTypes.php, inc/classes/Vendors.php etc.  Here is an example:

      var $join=array('Table1','Table2')
      This will create a join like "Select * FROM `Table1` LEFT JOIN `Table2` ON ..."

      Then I modified the modules/lookups/list.php around line 23:
          if (isset($do->join)) { //See if we need to join another table
              if(is_array($do->join)){  //If the join is an array then join those two tables first.
                  $rjo = DO_Common::factory($do->join[0]);
              } else {

      Could be useful for future versions.

    • Adam Moore

      Adam Moore - 2007-10-03

      Looking back on it I guess there wasn't any major changes. Oh well, since I made edits about 4 times before posting this it went from major to minor changes.


Log in to post a comment.