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.

Screencast tutorial series updates: Building a complete website using CodeIgniter 2 and ORM.

August 03, 2011 12:44pm

Subscribe [6]
  • #16 / Sep 14, 2011 4:28pm

    ShawnMcCool

    30 posts

    I just looked at the code for 2.0.3.  There was a change that broke Sparks.

    It looks like they changed _ci_autoloader() to ci_autoloader.

    Do not use 2.0.3 if you have any external code dependencies whatsoever.

    Thanks for your great screencast series.
    Yet i tried suggestion to replace _ci_autoloader and seems to still getting “Fatal error: Class ‘Users’ not found ...”:
    http://ellislab.com/forums/viewthread/199778/

    Not sure if I can try anything else?

    Gleb

    The issue is that your php-activerecord spark isn’t loading.  The fix to MY_Loader.php (replacing ALL instances of _ci_autoloader with ci_autoloader) should be enough to get this functionality back.  As a test, try to run $this->load->spark(‘php-activerecord’) before the User class is utilized.

  • #17 / Sep 14, 2011 4:35pm

    gesman

    9 posts

    I just looked at the code for 2.0.3.  There was a change that broke Sparks.

    It looks like they changed _ci_autoloader() to ci_autoloader.

    Do not use 2.0.3 if you have any external code dependencies whatsoever.

    Thanks for your great screencast series.
    Yet i tried suggestion to replace _ci_autoloader and seems to still getting “Fatal error: Class ‘Users’ not found ...”:
    http://ellislab.com/forums/viewthread/199778/

    Not sure if I can try anything else?

    Gleb

    The issue is that your php-activerecord spark isn’t loading.  The fix to MY_Loader.php (replacing ALL instances of _ci_autoloader with ci_autoloader) should be enough to get this functionality back.  As a test, try to run $this->load->spark(‘php-activerecord’) before the User class is utilized.

    I tried both and all combinations of above.
    This line works fine:
    $this->load->spark(‘php-activerecord’)

    But this line blows up with “Fatal error: Class ‘Users’ not found”:
    $users = Users::all();

    Advice to replace *all* occurences is misleading as there is a function definition for _ci_autoloader and replacing it causes redefinition error.
    In MY_Loader.php there is only one line that calls:
    $this->_ci_autoloader($spark_path);
    I tried replacing it - to no effect whatsoever. Same error.

    Gleb

  • #18 / Sep 14, 2011 4:46pm

    ShawnMcCool

    30 posts

    I tried both and all combinations of above.
    This line works fine:
    $this->load->spark(‘php-activerecord’)

    But this line blows up with “Fatal error: Class ‘Users’ not found”:
    $users = Users::all();

    Advice to replace *all* occurences is misleading as there is a function definition for _ci_autoloader and replacing it causes redefinition error.
    In MY_Loader.php there is only one line that calls:
    $this->_ci_autoloader($spark_path);
    I tried replacing it - to no effect whatsoever. Same error.

    Gleb

    You’ll notice that there are 2 references to _ci_autoloader in the tutorial’s MY_Loader class. 

    The first is:

    $this->_ci_autoloader($spark_path);

    The second is:

    function _ci_autoloader($basepath = NULL)

    Please review your MY_Loader.php.  Also, you may consider downloading the source (http://heybigname.com/files/part1.zip) and running a diff against your code.

  • #19 / Sep 14, 2011 5:02pm

    gesman

    9 posts

    I tried both and all combinations of above.
    This line works fine:
    $this->load->spark(‘php-activerecord’)

    But this line blows up with “Fatal error: Class ‘Users’ not found”:
    $users = Users::all();

    Advice to replace *all* occurences is misleading as there is a function definition for _ci_autoloader and replacing it causes redefinition error.
    In MY_Loader.php there is only one line that calls:
    $this->_ci_autoloader($spark_path);
    I tried replacing it - to no effect whatsoever. Same error.

    Gleb

    You’ll notice that there are 2 references to _ci_autoloader in the tutorial’s MY_Loader class. 

    The first is:

    $this->_ci_autoloader($spark_path);

    The second is:

    function _ci_autoloader($basepath = NULL)

    Please review your MY_Loader.php.  Also, you may consider downloading the source (http://heybigname.com/files/part1.zip) and running a diff against your code.

    Thanks for looking into it.

    Ok, your MY_Loader.php is a bit different from the one listed here:
    http://getsparks.org/install
    http://getsparks.org/static/install/MY_Loader.php.txt

    I tried both - including your + substituting underscore.

    Still doesn’t work. I don’t think this “political” underscore is an issue here though.
    The problem is that ./application/models/Users.php file is never loaded.
    I put a garbage inside to test - this file just never loaded, even though this line executes correctly:
    $this->load->spark(‘example-spark/1.0’);

    But then again - whether above line is present or absent - same error, no difference.

    Gleb

  • #20 / Sep 14, 2011 5:10pm

    ShawnMcCool

    30 posts

    Still doesn’t work. I don’t think this “political” underscore is an issue here though.
    The problem is that ./application/models/Users.php file is never loaded.
    I put a garbage inside to test - this file just never loaded, even though this line executes correctly:
    $this->load->spark(‘example-spark/1.0’);

    But then again - whether above line is present or absent - same error, no difference.

    Gleb

    Are you saying that if you manually attempt to load the php-activerecord spark version 0.0.1 the PHPActiveRecord class is never instantiated?

  • #21 / Sep 14, 2011 6:10pm

    gesman

    9 posts

    SOLVED:

    1. I downloaded wrong php-activerecord. This is the CORRECT link:
    http://getsparks.org/packages/php-activerecord/versions/HEAD/show

    2. It is no longer required to substitute _ci_autoloader within MY_Loader.php
    This latest version of MY_Loader.php solves it:
    http://getsparks.org/static/install/MY_Loader.php.txt

    Thanks to Shawn for grueling attempts to debug issues.

    Gleb

  • #22 / Sep 14, 2011 6:16pm

    ShawnMcCool

    30 posts

    Thanks to Matthew for grueling attempts to debug issues.

    Gleb

    lol, tell Matt i said hi.

    Anyway, you know where to find me.

  • #23 / Sep 14, 2011 6:18pm

    gesman

    9 posts

    Thanks to Matthew for grueling attempts to debug issues.

    Gleb

    lol, tell Matt i said hi.

    Anyway, you know where to find me.

    Gee, i meant “SHAWN”!!!!

    But I’ll tell Matt…. 😊

    Gleb

  • #24 / Sep 15, 2011 6:14pm

    ShawnMcCool

    30 posts

    I just uploaded a new screencast.  Part 5 begins covering ORM associations and discusses N+1.

    http://heybigname.com/2011/09/15/codeigniter-2-sparks-php-activerecord-part-5-orm-associations-and-n1/

  • #25 / Sep 15, 2011 6:15pm

    gesman

    9 posts

    Shawn, thanks so much!
    Your tutorials are the best. In fact right now i am working on derivative using your PHPAR source code samples….

    Gleb

  • #26 / Sep 16, 2011 5:24am

    Mat-Moo

    350 posts

    Nice TUTs even I have learnt something…

  • #27 / Sep 16, 2011 1:27pm

    gesman

    9 posts

    Shawn,
    When I add ‘created_at’ field to ‘users’, any attempt to User::create() blows up with:
    “Fatal error: Uncaught exception ‘ActiveRecord\DatabaseException’ with message ‘22007, 1292, Incorrect datetime value: ‘2011-09-16 18:22:57 CEST’ for column ‘created_at’  ...”

    Apparently PHP AR forces timezone into it: ‘2011-09-16 18:22:57 CEST’ but MySQL doesn’t like it (my guess).

    I tried to hook into before_create, before_validate to force-set $this->created_at to proper value, but PHP AR still over hooks it and over-forces it with value, polluted with timezone.
    As a test I changed ‘created_st’ to TEXT format - and it works and apparently the value in created table is *without* timezone string.

    But when ‘created_at’ in DATETIME format - it just fails as above.

    Do you know how to fix it?

    Thanks,

    Gleb

  • #28 / Sep 27, 2011 12:46pm

    ShawnMcCool

    30 posts

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

ExpressionEngine News!

#eecms, #events, #releases