The names of these methods should be fairly self explanatory. To make MyResult read only, you can implement offsetSet as

public function offsetSet($offset, $value) {}

The other methods are fairly straighforward. Once they are implemented, you can use the MyResult object as an array.

The problem is that I have very limited knowledge in how to revise class code - the instructions given weren't that clear. Can someone tell me if I need to replace the following block of code in my class file:

If so, is the above new code block syntax correct - I mean do I paste it exactly as above or am I missing some curly brackets etc.?

I'm not sure if revising the class code as advised above will eliminate the error and provide the functionality needed in order to make the code that I mentioned at the beginning of this post work. I'd just really appreciate someone helping so I can move a few steps forward.

I took a look at your code and while I am not very quick with OO code, I don't think you need to add that offset stuff to the MyResult class. The mistake is in the misuse of the $colours variable-- it is defined as an object that contains (represents is perhaps a better word) a query resource, but doesn't contain the actual data from that resource. You have to call the fetch_assoc() function of that class to actually pull the data out of the query.

So you should be able to leave the class untouched and simply modify the code around that line 109 to properly pull the data out of the query and then assign it to $values[$garment_id]['colour']. (line 285 does just that, FYI)

gwh

06-29-2007, 12:41 AM

Thanks for your reply,

It would be great if the solution were that simple. I'm not actually sure how to combined lines 285 and 109 below - can you be more specific as to how to do this?

Line 285
while ($row = $colours->fetch_assoc()) {

Line 109

$values[$garment_id]['colour'] = $colours[$i];

Fumigator

06-29-2007, 06:17 AM

Don't combine the two lines, just do what line 285 is doing. Right now you're using $colours as if it were the array built from the fetch_assoc() function in your MyResult class, but it's not the case... you simply need to call that function to get your data.

I take it you didn't write this code. The solution really is that simple... it may take some research on your part to figure out the PHP language, but once you do then you'll have gained tons of valuable PHP skillz. Use www.php.net as a reference.