Search code examples
mysqlrelationshipslithium

Multiple lithium models relationships


I´m actually on a project and working with lithium framework for PHP. I´m using multiple databases (MongoDB and MySQL) and on the MySQL database I have lots of many to many relations between my tables. I´ve been reading about lithium relationships between models and i found the "belongs to" relation. Is it possible to use this belongs to relation twice? if it is, can somebody explain me how?

Thanks in advance!


Solution

  • <?php
    
    class Posts extends \lithium\data\Model {
    
        public $belongsTo = ["Categories", "Users"];
    
        // -- or --
    
        public $belongsTo = ["Categories", "Author" => ["class" => "Users"]];
    }
    
    ?>
    

    Hope that helps.