In PHP, function references as parameters are passed as strings - so if you want to reference a class method - wrap it in an array with the 1st entry as the object of the method you are referencing and the 2nd entry is the string name of the function you want to call.
public function buildQueryResult($query) {
// [$this, 'buildSQLQueryResullt'] is our callback!
return ($this->cachingManager->get($query,[$this, 'buildSQLQueryResult']));
}
public function buildSQLQueryResult($query) {
$res = array() ;
$result = $this->mysqli->query($query);
if ($result) {
while ($row = $result->fetch_assoc()) {
array_push($res,$row) ;
}
}
return $res ;
}
public function buildQueryResult($query) {
// [$this, 'buildSQLQueryResullt'] is our callback!
return ($this->cachingManager->get($query,[$this, 'buildSQLQueryResult']));
}
public function buildSQLQueryResult($query) {
$res = array() ;
$result = $this->mysqli->query($query);
if ($result) {
while ($row = $result->fetch_assoc()) {
array_push($res,$row) ;
}
}
return $res ;
}
No comments:
Post a Comment