-4
public function update(){
    $query = "UPDATE `stock` SET `status`= 'expired'";
    $data =[$this->status];
    return $this->update($query, $data); //Error Line 
}

I have also used:

ini_set('memory_limit', '-1');

I Can anyone give me solution to this.

Simone Nigro
  • 4,717
  • 2
  • 37
  • 72
  • 2
    this function has infinite recursion: `$this->update($query, $data)` call `public function update()` that call `$this->update($query, $data)` – Simone Nigro Dec 23 '17 at 11:41
  • So, what can I do to now ? Is there any solution to this ? – sarina Byanjankar Dec 23 '17 at 12:41
  • @sarinaByanjankar you need to change the code and remove the infinite recursion.. only solution to this problem. – Raymond Nijland Dec 23 '17 at 12:42
  • If an answer solved your problem, consider accepting the answer. Here's how http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work then return here and do the same with the tick/checkmark till it turns green. This informs the community, a solution was found. Otherwise, others may think the question is still open and may want to post (more) answers. You'll earn points and others will be encouraged to help you. *Welcome to Stack!* – Jay Blanchard Dec 27 '17 at 14:34

1 Answers1

0

your code has infinite recursion

public function update(){                               // <--
    $query = "UPDATE `stock` SET `status`= 'expired'";  //    |
    $data =[$this->status];                             //    |                     
    return $this->update($query, $data);                //  --
}

the only solution is to change the code and remove the infinite recursion.

eg. rename public function update() into public function updateDb():

public function updateDb(){                             
    $query = "UPDATE `stock` SET `status`= 'expired'";  
    $data =[$this->status];                                                
    return $this->update($query, $data);                
}

after, refractoring your code and call updateDb() instead of update()

Simone Nigro
  • 4,717
  • 2
  • 37
  • 72