// Put fetched actions for each POI into an associative array. The returned values are assigned to $poi[actions]. // // Arguments: // poi ; The POI handler. // $db ; The database connection handler. // // Returns: // array ; An array of received actions for this POI. // function Getactions( $poi, $db ) { // A new table called “ACTION_Table” is created to store actions, // each action has a field called // “poiID” which shows the POI id that this action belongs to. // The SQL statement returns actions which have the same poiID as the // id of $poi ($poi[‘id’]). $sql_actions = $db->prepare( “ SELECT label, uri, autoTriggerRange, autoTriggerOnly, contentType, method, activityType, params, closeBiw, showActivity, activityMessage FROM ACTION_Table WHERE poiID = :id “ ); // Binds the named parameter markers “:id” to the specified // parameter values “$poi[‘id’]”. $sql_actions->bindParam( ‘:id’, $poi[‘id’], PDO::PARAM_INT ); // Use PDO::execute() to execute the prepared statement $sql_actions. $sql_actions->execute(); // Iterator for the $poi[“actions”] array. $count = 0; // Fetch all the poi actions. $actions = $sql_actions->fetchAll( PDO::FETCH_ASSOC ); /* Process the $actions result */ // if $actions array is empty, return empty array. if ( empty( $actions ) ) { $poi[“actions”] = array(); }//if else { // Put each action information into $poi[“actions”] array. foreach ( $actions as $action ) { // Assign each action to $poi[“actions”] array. $poi[“actions”][$count] = $action; // put ‘params’ into an array of strings $paramsArray = array(); if ( substr_count( $action[‘params’],’,’ ) ) { $paramsArray = explode( “,”, $action[‘params’] ); }//if else if( strlen( $action[‘params’] ) ) { $paramsArray[0] = $action[‘params’]; } $poi[“actions”][$count][‘params’] = $paramsArray; // Change ‘activityType’ to Integer. $poi[“actions”][$count][‘activityType’] = ChangetoInt( $poi[“actions”][$count][‘activityType’] ); // Change the values of “closeBiw” into boolean value. $poi[“actions”][$count][‘closeBiw’] = ChangetoBool( $poi[“actions”][$count][‘closeBiw’] ); // Change the values of “showActivity” into boolean value. $poi[“actions”][$count][‘showActivity’] = ChangetoBool( $poi[“actions”][$count][‘showActivity’] ); // Change ‘autoTriggerRange’ to Integer, if the value is NULL, // return NULL. $poi[“actions”][$count][‘autoTriggerRange’] = ChangetoInt( $poi[“actions”][$count][‘autoTriggerRange’] ); // Change the values of “autoTriggerOnly” into boolean value, // if the value is NULL, return NULL. $poi[“actions”][$count][‘autoTriggerOnly’] = ChangetoBool( $poi[“actions”][$count][‘autoTriggerOnly’] ); $count++; }// foreach }//else return $poi[“actions”]; }//Getactions //Convert a TinyInt value to a boolean value TRUE or FALSE // Arguments: // value_Tinyint ; The Tinyint value (0 or 1) of a key in the database. // Returns: // value_Bool ; The boolean value, return ‘TRUE’ when Tinyint is 1. // Return ‘FALSE’ when Tinyint is 0. // function ChangetoBool( $value_Tinyint ) { if ( $value_Tinyint == 1 ) $value_Bool = TRUE; else $value_Bool = FALSE; return $value_Bool; }//ChangetoBool