0

I have a structure like this:

class DataList { 
... 
 public function fetchData(){
 ...
 $this = $statement->fetchAll(PDO::FETCH_CLASS,"DataList");
 }
}

I want the db query result to set member variables matching field names. But I'm getting an error:

Fatal error: Cannot re-assign $this in C:\xampp\htdocs\adk3\classes\DataList.php
on line 11
Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
Rápli András
  • 3,869
  • 1
  • 35
  • 55

1 Answers1

0

$this is a read-only variable. It is just a pointer to current object, allowing you to access it's properties and methods. You can't assign anything to it.

wesolyromek
  • 650
  • 1
  • 6
  • 17