Posted by David Haynes on 07/05/06 11:51
Dodger wrote:
> David Haynes wrote:
>> Dodger wrote:
>> [snip]
>
>> The store->result() method returns a mysqli_result type.
>> You need to use the mysqli_type for the fetch_assoc() method.
>
> Thank you!
>
> Though pardon my saying that that's weird as snake shoes...
> Result objects... *blinks*
Well... its not all that uncommon. Java, for example, hands you a result
which you then have to play with.
>> $cities = array();
>> while( $city = $result->fetch_assoc() ) {
>> $cities[] = $city; // you don't need to supply the $i++ index this way
>> }
>
> I think ... I think I'm gonna end up writing function push {} -- to
> preserve my sanity by doing that bit elsewhere hidden away...
The [] operator is a push operator.
>> $result->free(); // don't forget to free the result memory
>
> Is there a way to lexically scope things, something like my() in
> Perl... so the garbage handling bit can be taken care of automagically
> when things fall out of scope?
>
No. Not really. PHP doesn't really have a good model for memory
management - its based more upon the C(++) of malloc/free. i.e. You are
a big boy and should clean up your own messes.
-david-
[Back to original message]
|