Example #1
0
 public function request($request, $options = array())
 {
     if ($this->link) {
         // Execute the request and build a response object
         $raw = mysql_query($request, $this->link);
         $data = new Org_Apache_Oodt_Balance_Core_ApplicationDataResponse();
         if ('' != ($errMessage = mysql_error($this->link))) {
             $data->setError($errMessage);
             return $data;
         } else {
             // Handle associative array
             if (isset($options['format']) && strtolower($options['format']) == 'assoc') {
                 $idx = 0;
                 while (false !== ($row = mysql_fetch_assoc($raw))) {
                     if (isset($options['indexKey'])) {
                         $data->add($raw[$options['indexKey']], $row);
                     } else {
                         $data->add($idx++, $row);
                     }
                 }
             } else {
                 $idx = 0;
                 while (false !== ($row = mysql_fetch_row($raw))) {
                     if (isset($options['indexKey'])) {
                         $data->add($raw[$options['indexKey']], $row);
                     } else {
                         $data->add($idx++, $row);
                     }
                 }
             }
             // Store the request used to generate the data
             $data->setRequestString($request);
             // Free the request
             mysql_free_result($raw);
             // Return the requested data
             return $data;
         }
     } else {
         $data = new Org_Apache_Oodt_Balance_Core_ApplicationDataResponse();
         $data->setError("Unable to establish connection to data source");
         return $data;
     }
 }
Example #2
0
 public function lastInsertedId($options = array())
 {
     $data = new Org_Apache_Oodt_Balance_Core_ApplicationDataResponse();
     if ($this->link) {
         $result = $this->link->lastInsertId();
         if (PEAR::isError($result)) {
             $data->setError($result->getMessage());
             return $data;
         } else {
             return $result;
         }
     } else {
         $data->setError("Unable to establish connection to data source");
         return $data;
     }
 }
Example #3
0
 public function lastInsertedId($options = array())
 {
     $data = new Org_Apache_Oodt_Balance_Core_ApplicationDataResponse();
     if ($this->link) {
         try {
             $lastId = $this->link->lastInsertId();
         } catch (PDOException $e) {
             $data->setError($e->getMessage());
             return $data;
         }
         return $lastId;
     } else {
         $data->setError("Unable to establish connection to data source");
         return $data;
     }
 }