All pastes #21875 Raw Edit

Anonymous

public text v1 · immutable
#21875 ·published 2005-09-01 21:06 UTC
rendered paste body
/**
        * This global function loads the first row of a query into an object
        *
        * If an object is passed to this function, the returned row is bound to the existing elements of <var>object</var>.
        * If <var>object</var> has a value of null, then all of the returned query fields returned in the object.
        * @param string The SQL query
        * @param object The address of variable
        */
        function loadObject( &$object ) {
                if ($object != null) {
                        if (!($cur = $this->query())) {
                                return false;
                        }
                        if ($array = mysql_fetch_assoc( $cur )) {
                                mysql_free_result( $cur );
                                mosBindArrayToObject( $array, $object, null, null, false );
                                return true;
                        } else {
                                return false;
                        }
                } else {
                        if ($cur = $this->query()) {
                                if ($object = mysql_fetch_object( $cur )) {
                                        mysql_free_result( $cur );
                                        return true;
                                } else {
                                        $object = null;
                                        return false;
                                }
                        } else {
                                return false;
                        }
                }
        }