ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Doctrine installation under windows

February 18, 2008 6:25pm

Subscribe [2]
  • #1 / Feb 18, 2008 6:25pm

    ci_man

    9 posts

    Hi,

    I am trying to install Doctrine(ORM) and I am following the instructions from http://codeigniter.com/wiki/Using_Doctrine_with_Code_Igniter/

    I get to the step—Setup Command Line Interface. It says I need to
    create a executable file by,

    vi system/application/doctrine

    How do I do it under windows? Have anyone successfully installed Doctrine/CI/windows?
    Do you think the above document would also work for windows?

    Any input would be very appreciated!!!

  • #2 / Feb 18, 2008 7:17pm

    Rick Jolly

    729 posts

    Those instructions are scary. Seems like the author made a lot of assumptions.

    I played with Doctrine a while ago. Things may have changed since then, but here is what I did:
    http://ellislab.com/forums/viewthread/56264/P10/#291714.

  • #3 / Feb 18, 2008 9:04pm

    ci_man

    9 posts

    Thanks!!! Rick.

    But I still have a couple of questions since I am new to CI (less than 48 hours).

    In your step 1,

    which script do I put this code?
    require_once(APPPATH . ‘/libraries/doctrine/lib/Doctrine.php’);

    In step 3,

    How do I create these database object classes (I don’t have command line under windows)?
    Could you please include one example of doctrine usage? maybe one piece of your code, so that I can learn by examples?

  • #4 / Feb 18, 2008 9:43pm

    Rick Jolly

    729 posts

    This is going from old test code, so you’ll have to read the doctrine manual as well.

    Thanks!!! Rick.

    But I still have a couple of questions since I am new to CI (less than 48 hours).

    In your step 1,

    which script do I put this code?
    require_once(APPPATH . ‘/libraries/doctrine/lib/Doctrine.php’);

    Where ever you are using doctrine. If you “compiled” it into one php file (if that is still an option):

    require_once(APPPATH . '/libraries/doctrine/lib/Doctrine.compiled.php');
    
    class Somecontroller extends Controller 
    {
       function index()
       {
          $user = new User();
          $user->name = 'Bjarte S. Karlsen';
          $user->find();
          if($user !== false)
          {
             echo('user name: ' . $user->name);
          }
       }
    }

    In step 3,

    How do I create these database object classes (I don’t have command line under windows)?
    Could you please include one example of doctrine usage? maybe one piece of your code, so that I can learn by examples?

    You don’t need the command line. You just need to run a script once so that doctrine can generate model classes from your existing database. It can also work the other way and create database tables from your model classes. I’d suggest reading the manual, but after I created a “doctrine” folder in models, I ran this code from my controller once:

    // add a password to the connection string if you have one
    $conn = Doctrine_Manager::connection('mysql://root@localhost/your_db');
    $conn->import->importSchema(APPPATH . '/models/doctrine');
  • #5 / Feb 18, 2008 10:09pm

    ci_man

    9 posts

    crystal clear! Thanks Rick, I really appreciate it!
    I will try it out. If it works, I will put it on this forum, step by step. Hopefully it helps others too.

  • #6 / Feb 19, 2008 3:42pm

    ci_man

    9 posts

    sorry, Rick, I could not make it work… Could you please take a look what I did wrong?

    Here are my steps,
    1)Download doctrine into a folder called “Doctrine”;
    2)Write a script with following codes,

    require_once(‘Doctrine/lib/Doctrine.php’);
    spl_autoload_register(array(‘Doctrine’, ‘autoload’));
    Doctrine_Manager::connection(‘mysql://user:password@localhost/project1’);
    Doctrine::generateModelsFromDb(‘myModel’);

    3)After running this script, I got myModel folder, which has a generated folder and Student.php (from my database)
    4)Then I compiled doctrine by this script,

    require_once(‘Doctrine/lib/Doctrine.php’);
    spl_autoload_register(array(‘Doctrine’, ‘autoload’));
    Doctrine::compile();

    5) And I saw a new file Doctrine.compiled in the lib folder.
    6) Now I try to create a new file to test, here is the code,

    require_once(‘Doctrine/lib/Doctrine.compiled.php’);
    require_once(‘myModel/Student.php’);
    echo “include success”;

    When I run this code, it did not print out “include success”. What did I do wrong?
    If I comment out require_once(‘myModel/Student.php’), it will print out.

    Thanks for all your help.

  • #7 / Feb 22, 2008 2:48am

    Rick Jolly

    729 posts

    Looks to me like you’re almost there.

    The problem seems to be an invalid path in your require(). If so, then nothing to do with Doctrine. But it could be in the Student model. I can’t debug this without errors though.

    Is your error reporting set to E_ALL? Did you check the error log?

    Where are you running the scripts? Could it be that the path to the model you are requiring isn’t correct? That is, it isn’t relative to your script. You probably know this, but you can use absolute paths using the CI global APPPATH as a start.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases