Welcome Guest, Not a member yet? Register   Sign In
Model Class Problem
#1

[eluser]Unknown[/eluser]
I have my add() function in the controller..

Code:
function add(){
      
        $this->load->model('FeedList');
        $feedList = new FeedList();
        $rs = $feedList->add( $_POST['url'] );
      
        echo $rs;
    }

When I call this function, I get this error:
Fatal error: Using $this when not in object context in C:\xampp\htdocs\RSS\system\application\models\FeedList.php on line 13

this is my feedList.php file:

Code:
class FeedList extends Model {
  
    public function __construct(){
        parent::Model();
    }
  
  public static function add( $url ) {
       //bottom line I get error, getFeedByUrl()
    if ( $this->getFeedByUrl( $url ) != null ) return "fail";
.
.
.
}

Anyway seems to be I cannot create a FeedList class inside of the FeedList class..

I already try construct() function it didnt work.
Can you tell me where I do wrong? Thanks..
#2

[eluser]Delian Angelov[/eluser]
hm, this:
Code:
public static function add( $url ) {

probably should be :

Code:
public function add( $url ) {


?

just my 2 cents ...
#3

[eluser]Unknown[/eluser]
Thank you!! Smile
I didint notice that!

I will give you 2 cents just give me your bank account number Smile




Theme © iAndrew 2016 - Forum software by © MyBB