referencing objects within objects
| From: | TSHACK | Date: | Fri, 17 Nov 2000 13:44:46 +0000 |
| Subject: | referencing objects within objects | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-25900@lists.php.net to get a copy of this message | ||
I have an object called formCass. Referencing things like $this->sql are no
problem.
I also have an array, $this->fields, which is an array of fieldClasses
within formClass.
Within the fieldClass, I do a mysql_fetch_field.
Wait, here's the code:
<?
class fieldClass {
var $fetchresult;
var $table_result;
var $input_type; // text, select, radio, hidden
var $sql; // sql statement for select input_type
var $title; // display name for field on form
var $edit_option; // view-only, edit, hidden
var $validate; // function call to validation procedure.
var $input_mask; // text of input mask for field.
// Methods definition
function fieldClass ($result, $field_ofs)
$fetchresult = @mysql_fetch_field($result, $field_ofs) or die("Fetch
Result
failed");
echo "<PRE>
blob: $fetchresult->blob
max_length: $fetchresult->max_length
multiple_key: $fetchresult->multiple_key
name: $fetchresult->name
not_null: $fetchresult->not_null
numeric: $fetchresult->numeric
primary_key: $fetchresult->primary_key
table: $fetchresult->table
type: $fetchresult->type
unique_key: $fetchresult->unique_key
unsigned: $fetchresult->unsigned
zerofill: $fetchresult->zerofill
</PRE>";
}
} // end of field class definition
?>
OK, this works:
blob: $fetchresult->blob
but I want to be able to reference
$fieldClass->fetchresult->blob
or even
$this->fetchresult->blob
So that the contents will be viewable up at the formClass level (I'm really
new to all of this, so I've probably shot myself in the foot on three levels
already).
In essense, I want to be able to reference the contents of $fetchresult
array as a property of the formClass. I'm assuming that if its just a
function variable, it will disappear when the function ends.
What is the referencing structure when going down into classes within
classes like this? Is there another route I should be pursuing?
Yes, I've read through the manual, but the places I thought of to look don't
cover this. I probably haven't looking in the right place. Just a pointer
to the proper subject matter will be helpful.
What I have started doing is creating functions within the class to return
these variables, and functions to set them, like gets and sets in VB, but if
there is a less tedious way to do this, I would appreciate knowing it.
Dwight