Actually, allow me to correct one thing. This is an N-dimensional array
(depending on the depth). But you are handling it as a single
dimensional array in your recursive function. This is perfectly fine,
and I do similar things quite regularly.
I happy to hear that. It is good to listen that I haven't used a
technique that is so awkward to be used from otheres.
At the moment what I did with my ricursive function works perfect.
The question is if that's the right way to do it...
And that is an object haveing as an attribute another object and that
object laso have another object as an attribute:
oject -object -object
or is it better to keep them sepperate and just use their unique id's
to link the two objects (thats what I am doing until now)
So again:
1st way *************** *************** *
*************** *************** ***********
class package {
var $packageId;
var $productArray = array();
function package($packag eId=NULL) {
$this->packageId = $packageId;
$this->productArray = product::select (....);
}
}
class product {
var $productId;
var $attributesArra y = array();
function product($produc tId=NULL) {
$this->productId = $productId;
$this->attributesArra y = attribute::sele ct(....);
}
}
2nd way *************** *************** *
*************** *************** ***********
class package {
var $packageId;
function package($packag eId=NULL) {
$this->packageId = $packageId;
}
}
class product {
var $productId;
function product($produc tId=NULL) {
$this->productId = $productId;
}
}
$product_packag es = select the products from product_package table
//$product_packag es = array('pacakge_ id','product_id ') <- just to have
an idea of how that array looks like
foreach($produc t_packages as $packageId =$productArray) {
foreach($produc tArray as $productId =$productValue) {
$product[$productId] = new product($produc tId);
}
}
Anyway... that's not like the full code but you could get an Idea of
how I am working...
I hope it makes sense.
Can you just tell me which way could be better ? more efficient
probably ...
At the moment for every Many to Many relationship I am using a
seperate class e.g. product_package
Thanks
Angelos