I am having a strange issue with my php code. This is the php version I am using PHP 5.3.2-1ubuntu4.30 with Suhosin-Patch.
The issue I am having is that I cannot assign an anything to a variable that is part of my class
namespace Stats\POTSPortStats;
use PDO;
use Stats\Port;
use Stats\POTSPortStats\IPHosts\IPHosts;
class PortStats extends Port
{
public $vcPortOnHookStatus;
public $vcPortImpedance;
public $ipHosts;
/**
* @param $secretValue int
* @param $pdo_conn PDO
* @return PortStats[]
*/
public static function getAll($secretValue, $pdo_conn){
try {
$query =
"SELECT * FROM secretTable WHERE secretColumn = :secretValue";
$pdo_stmt = $pdo_conn->prepare($query);
$pdo_stmt->bindValue(":secretValue", $secretValue, PDO::PARAM_INT);
$pdo_stmt->execute();
/** @var PortStats $result */ //This works right
$result = $pdo_stmt->fetchAll(PDO::FETCH_CLASS, __CLASS__);
//other is assigned an Array of IPHosts classes
$other = IPHosts::getAll($secretValue, $pdo_conn);
echo json_encode($other);
//Checked for result, it is there.
$result->ipHosts = $other;
//Check just assigned value
var_dump($result->ipHosts);
//Value was NULL
} catch (\PDOException $e) {
//nothing here
var_dump($e);
}
//The rest of the result is returned correctly
return $result;
}
Is there something wrong with my code that I am overlooking? Is there some kind of bug inside of this version of PHP that I did not find when I looked? Any help would be much appreciated. Please ask if you need more clarification.
ini_set('display_errors', '1');anderror_reporting(E_ALL);.UPDATE. Also remember your variables arenon-staticyet your function isstatic.