Welcome Guest, Not a member yet? Register   Sign In
How i can use model in other model?
#2

[eluser]Phil Sturgeon[/eluser]
Sadly models are not loaded in the model class, so using $this-> doesnt give you any access to them. You need to grab the instance using get_instance() then use THAT new object pointer to access your models.

Code:
<?php
class Posts extends Model {
  
  function Posts() {
    parent::Model();
  } // Posts

  
    function getPostOrderId($id) {
        $CI =& get_instance();
        $CI->load->model('comments');
        
        $comments = $CI->comments->getCommentsForPost($id);
        return $result;        
    }    

} // class Posts
?>


Messages In This Thread
How i can use model in other model? - by El Forum - 12-30-2007, 06:09 AM
How i can use model in other model? - by El Forum - 12-30-2007, 07:32 AM
How i can use model in other model? - by El Forum - 12-30-2007, 07:39 AM
How i can use model in other model? - by El Forum - 12-30-2007, 07:46 AM
How i can use model in other model? - by El Forum - 12-30-2007, 07:55 AM
How i can use model in other model? - by El Forum - 01-05-2008, 01:02 PM
How i can use model in other model? - by El Forum - 01-05-2008, 01:08 PM
How i can use model in other model? - by El Forum - 01-05-2008, 01:19 PM
How i can use model in other model? - by El Forum - 01-05-2008, 01:34 PM
How i can use model in other model? - by El Forum - 01-05-2008, 01:48 PM



Theme © iAndrew 2016 - Forum software by © MyBB