Welcome Guest, Not a member yet? Register   Sign In
How can I use a model function in the same model
#1

[eluser]Wathfea[/eluser]
Hi All!

I have a function which rerturn a value from the DB. How could I call this function in the same model?
Code:
<?php

class Admin_model extends CI_Model {

    function __construct() {
        parent::__construct();
    }

public function get_something($id) {
  //SQL bla bla . Request by id
  return $result;
}

public function something() {
get_something('2');   // I Think its not right
}
#2

[eluser]CroNiX[/eluser]
Code:
public function something() {
  $this->get_something('2');
  //or
  self::get_something(2);
}
#3

[eluser]Wathfea[/eluser]
Thx a lot working like a charm. Smile
#4

[eluser]www.sblog.in[/eluser]
when you are using the function from same class and if no other class will use that function then why don't you make that private

private function get_something($id) {
//SQL bla bla . Request by id
return $result;
}




Theme © iAndrew 2016 - Forum software by © MyBB