topical media & game development

talk show tell print

#mobile-ar-8-12.txt / txt



  // Put fetched object related parameters for each POI into an associative
  // array. The returned values are assigned to poi[object].
  //
  // Arguments:
  // poi ; The POI handler.
  // db ; The database connection handler.
  //
  // Returns:
  // array ; An array of received object related parameters for this POI.
  //
  
  function Getobject( poi, db ) {
          // A new table called “OBJECT_Table” is created to store object related
          // parameters, namely “baseURL”, “full”, “reduced”, “icon”, and “size”.
          // “poiID” which shows the POI id that this object belongs to.
          // The SQL statement returns object which has the same poiID as
          // the id of poi (poi[‘id’]).
  
          sql_object = db->prepare( “ SELECT baseURL, full, reduced, icon, size
          FROM OBJECT_Table
          WHERE poiID = :id
          LIMIT 0,1 “ );
  
          // Binds the named parameter markers “:id” to the specified parameter
          // values “poi[‘id’]”.
  
          sql_object->bindParam( ‘:id’, poi[‘id’], PDO::PARAM_INT );
          // Use PDO::execute() to execute the prepared statement sql_object.
          sql_object->execute();
          // Fetch the poi object.
  
          object = sql_object->fetchAll( PDO::FETCH_ASSOC );
          /* Process the object result */
  
          // if object array is empty, return NULL.
          if ( empty( object ) ) {
                  poi[“object”] = null;
          }//if
          else {
  
          // Since each POI only has one object. Logically, only one object should
          // be returned. Assign the first object in the array to poi[“object”]
  
          poi[“object”] = object[0];
          // Change “size” type to float.
          poi[“object”][“size”] = ChangetoFloat( poi[“object”][“size”] );
          }//else
          return poi[“object”];
  }//Getobject


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.