Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Kohana's ORM ported to Fuel
  • Added count_ to magic methods.
    Ie:
    Model_Client::count_by_last_name('corlett');
    (returns the count of how many results were found)
    
  • count_by_ is now count_all_by_ (for consistency's sake).
    if (Model_Client::count_all_by_last_name('corlett'))
    {
        // do something
    }
    
  • Updated Kohana ORM - for anyone using it, your classes must now extend \Kohana\Orm instead of \ORM\ORM. this is to make way for the native ORM coming in, giving people a choice without causing conflict.
  • Hi, I am having a few problems with this, just wondering if you can point where I am going wrong: // FILE: modules/article/classes/model/article.php
    <?php
    
    namespace Article;
    
    class Model_Article extends \ORM
    {
        protected $_belongs_to = array('news' => array(
     'model' => 'Model_News'
        ));
    }
    

    // FILE: modules/article/classes/model/news.php
    <?php
    
    namespace Article;
    
    class Model_News extends \ORM
    {
        protected $_table_name = 'news';
    
        protected $_has_one = array('articles' => array(
     'model' => 'Model_Article'
        ));
    }
    

    // FILE: modules/article/classes/controller/admin.php
    <?php
    
    namespace Article;
    
    class Controller_Admin extends \Controller_Adminbase
    {
        public function action_index()
        {
     $articles = new Model_Article();
     $articles->title = 'Theme Park Explodes';
     $articles->datetime_create = 1298137190;
     $articles->datetime_lastedit = 1298137190;
     $articles->article = 'Here is some content';
     $articles->author_create = 12;
     $articles->author_lastedit = 12;
     $articles->save();
    
     $news = new Model_News();
     $news->post_datetime = 1298137190;
     $news->post_user = 43;
     $news->save();
    
     $news->add('article',$articles);
     
     /*$this->content = \View::factory('articlehome')->render();
     $this->title = 'Article Admin';
     $this->draw();*/
        }
    }
    

    The database tables are called Articles and News. News has article_id set as an int. When I try and run the controller code I end up getting a number of errors: ErrorException [ Notice ]: Undefined index: article (line 1082 PKGPATH/orm/classes/kohana/orm.php)
    ErrorException [ Notice ]: Undefined index: article (same)
    ErrorException [ Notice ]: Undefined index: article (line 1092 PKGPATH/orm/classes/kohana/orm.php)
    Fuel\Core\Database_Exception [ 1103 ]: Incorrect table name '' [ INSERT INTO `` (``, ``) VALUES (6, 6) ] (line 180 COREPATH/classes/database/mysql.php) If someone could please point out where I am going wrong would be good, as I have never used Kohana's ORM before. It seems similar enough to Datamapper DMZ over at CodeIgniter, but have followed instructions in the readme file and still no joy. Thanks in advance. Ian
  • Hey Ian, Sorry about the late reply I've been flat-out lately. I"ll have a look into it just now and I'll have an answer for you in a minute or two
  • Hey Ian, I can't seem to duplicate the problem in a new installation of Fuel. Could you make a zip archive of your installation (with an mysql dump) and email it to me at
    bencorlett [at] me [dot] com
    

    Cheers mate
  • Hey dude,
    Fuel\Core\Autoloader::add_classes
    

    Should be:
    Autoloader::add_classes
    

    this commit changed the bootstrap.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion