still getting used to PHP classes so a bit of "help /guidance" please
I have a class like this:
class ansa_accounturl_query {
function __construct() {
global $DBH;
global $limit;
$STH = $DBH->query("SELECT frm_url.frm_urlID,frm_url.frm_url FROM frm_url WHERE frm_url.accountID='SOMETHING' ".$limit." ");
$STH->setFetchMode(PDO::FETCH_OBJ);
$this->noforms = $STH->rowCount();
while($row = $STH->fetch()):
$this->frm_urlID[] = $row->frm_urlID;
$this->frm_url[] = $row->frm_url;
endwhile;
}
}
The limit comes from a PHP function - and works.
What I would really like to do is create extend classes for the above example which gives say $this-frm_url
as a function. so that on the "page" I call the class $classcall = new class();
but rather than have to go echo $classcall->frm_url[$key];
I can just call a function like this echo frm_url();
So in the example above there would be 2 extend classes one for frm_urlID and one for frm_url.
Also, in the "master class" am I right in in setting as array? i.e. $this->frm_url[]
as without that I cannot seem to run a loop but the loop does seem "over" complex if you do it this way as you (well I) have to get a count of the array items then run the loop so you (again I) have a for()
statement then a foreach()
. Seems longwinded to me.
Thanks in adavance.