We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22303 MODX Staff
    • 10,725 Posts
    Quote from: Everett at Sep 23, 2009, 12:14 AM

    I don’t know if this has a place in Revolution or not... I’m waiting for Jason to weigh in. xPDO is an ORM, and Revo has a much more developed API...

    The main reason I’m looking at this very seriously at the moment is I have to connect with an Oracle database, and CodeIgniter’s active record API would allow for that.
    I’m trying to restrain myself; I made my opinion on this pretty clear in my previous post: I don’t see the point in mixing CI and MODx. They are both essentially MVC; but one’s for those that need a CMS to separate presentation and logic, and one is for pure PHP developers that want to write everything in PHP "views". As for connecting to Oracle, you can do that from any PHP page; you don’t need CI’s Active Record implementation for that. Just use PDO with Oracle drivers. Since xPDO is a wrapper for PDO, you can do all of that from xPDO as well. Loading two frameworks IMO is, well, definitely not a scalable solution; I’ll leave it at that.
      • 24935
      • 160 Posts
      Quote from: Everett at Sep 23, 2009, 12:14 AM

      Or... I also wonder if you couldn’t do something similar that instantiated a new MODx object within a CI library or helper, then just use the same MODx API stuff within that object right inline with your CI controller or model code.

      The global modx variable is already available. Just put
      global $modx; 
      

      into your codeignitor script and then you can access everything.

      I actually have never used CodeIgnitor for any projects yet. I just saw some demos and played with some examples. I did this integration to see what would happen. I have yet to try it out for anything serious. I have been wanting to learn a PHP framework for a while, and CI has good documentation, was easier to figure out than Cake, and I hear that it has a very active and helpful community not unlike MODx. I hope that this bridge will encourage CI users to try out MODx, and that there will be some cross-fertilization of ideas between the two projects. CodeIgnitor definately has some good ideas that MODx can learn from, and vice versa (for example, I think MODx handles views better than CI).

      For anyone who would rather use CI as a snippet, you can make a snippet and name it ciinc, with this code:
      <?php
      $cibridge['error_reporting'] = ini_get('error_reporting');
      $cibridge['display_errors'] = ini_get('display_errors');
      if(isset($_SERVER['PATH_INFO'])) $cibridge['PATH_INFO'] = $_SERVER['PATH_INFO'];
      if(isset($_SERVER['REQUEST_URI'])) $cibridge['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
      if(isset($_SERVER['QUERY_STRING'])) $cibridge['QUERY_STRING'] = $_SERVER['QUERY_STRING'];
      if(isset($_GET['q'])) $cibridge['q'] = $_GET['q'];
      
      if(!isset($path)) 
         $path = isset($_GET['q']) ? $_GET['q'] : '';
      $path = '/' . $path;
      $_SERVER['PATH_INFO'] = $path;
      $_SERVER['REQUEST_URI'] = $path;
      unset($_GET['q']);
      
      
      ob_start();
      include('../ci/index.php');
      $output = ob_get_contents();
      ob_end_clean();
      ini_set('error_reporting', $cibridge['error_reporting']);
      ini_set('display_errors', $cibridge['display_errors']);
      if(isset($cibridge['PATH_INFO'])) $_SERVER['PATH_INFO'] = $cibridge['PATH_INFO'];
      if(isset($cibridge['REQUEST_URI'])) $_SERVER['REQUEST_URI'] = $cibridge['REQUEST_URI'];
      if(isset($cibridge['QUERY_STRING'])) $_SERVER['QUERY_STRING'] = $cibridge['QUERY_STRING'];
      if(isset($cibridge['q'])) $_GET['q'] = $cibridge['q'];
      
      return $output;
      ?>
      
        • 9207 ☆ A M B ☆
        • 2,475 Posts
        Thanks, Jason. I can see the inefficiencies stacking up using 2 frameworks, certainly... however, I can’t help myself appreciating CodeIgniter’s thorough documentation.

        For this project I’m working on, the corp. keeps changing its mind about the external content database... MySQL one day, Oracle the next, so using something like xPDO is an obvious way to go so we can be database agnostic with our code.... although CI’s Active Record approach is probably sufficient for this particular project.

        The big difference right now as I see it is the documentation. I know I can make this work in CodeIgniter... I know it’s possible (perhaps preferable) to do this in Revolution if there is a significant content portion to the web site, but I just haven’t seen many examples / specific cases demonstrating how to do database interactions.

        I’m probably nominating myself for this (gulp), but it would be really useful to see side-by-side comparisons or even basic walk-throughs of how to do certain things using MODx vs. CI. Anyone got some favorite links for this type of thing?