I am quietly going bonkers. I can use methods and classes fine but attributes I am going lala!
<?php require_once ($_SERVER['DOCUMENT_ROOT'] ."/beta02/inc-head.php");
//set up functions and pdo
class Schedule{
public $_day= 'Sending day(s) not set';
protected $_dayId= 'Sending time not set';
protected $_transmissionId= 'Sending time not set';
public $transmissionIdArray = array() ;
public function retrieveTransmission($person){
$this->person = $person;
try
{
global $pdo;
$sql =
"SELECT id FROM transmission
WHERE person_id = :person;";
$statement = $pdo->prepare($sql);
$statement->bindParam(':person',$person, PDO::PARAM_INT);
$statement->execute();
$result=$statement ->fetchAll(PDO::FETCH_BOTH);
foreach ($result as $value)
{
array_push($this->transmissionIdArray,$value['id']);
//echo $value["id"];
}
$out=$this->transmissionIdArray;
return($out);
}
catch (PDOException $e)
{
$output = 'Error getting messages ready to display #6734: ' . $e->getMessage();
include $_SERVER['DOCUMENT_ROOT'] ."/vvvxxx/includes/output.html.php";
exit();
}
debug ($this->transmissionIdArray,"trans array");
}
}
This works fine … up to a point!
$myClass= new Schedule;
$xxxx = $myClass->retrieveTransmission (2);
echo implode ($xxxx);
Works fine. But how do I access public scalars like $day or, more importantly arrays. This is just during the building and testing phase. Once working vaguely OK they will go back to being protected.
I tried:
$xxxx=$myClass->$transmissionIdArray;
echo implode ($xxxx);
I tried (optimistically):
echo implode ($transmissionIdArray);
and
$xxxx=$myClass->$day...
But could get nothing to work. So newb question: How do I simply grab public values (esp arrays) from an instance of a class?
I know this must be in Class class 101 but I am old and forgetful and have wasted about an hour looking for the answer (might have something to do with four hours sleep).
TIA for any help.
PS I would never DARE to post something like this on Stack Exchange
PPS Is there any way to make the posting text area bigger. Really horrible to try and post while looking through a tiny letterbox!