Welcome Guest, Not a member yet? Register   Sign In
passing variable in model
#1

PHP Code:
function get_articles() {
    $articles $this->db->query("SELECT * FROM tbl_articles WHERE status = '1' AND lang = '$this->locale' ORDER BY id DESC");    foreach($articles->getResult('array') as $a) {
      $articleId $a['id']; // I would like pass this variable to get_ip function
    }
    return $articles;
  }  

function get_ip() {
    $test $this->db->query("SELECT * FROM tbl_images_preview WHERE article_id = ".$articleId."");
    return $test;
  

I have this snippet in my model. How can I pass the variable $articleId to get_ip function?

Thanks. Smile
Reply
#2

Before the return of $articles, use a loop to iterate through each article int he list one at a time and call get_ip() one each one in the loop. Then do something with the result that is passed back.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB