Example #1
0
 /**
  * executes a SQL and returns a result dataset if appropriate.  Use PDO object instead of execSQL() command as mysql_ functions are no longer maintained and have been deprecated.
  * @param string $sql Prepared SQL statement. Use ? character for placeholders
  * @param array $paramArray Array of parameters to apply into the prepared SQL statement.  Values are replaced in sequence.
  * @param string $db Name of the database to execute the query against
  */
 public static function execPDO($sql, $paramArray, $db)
 {
     // get more reference from http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers
     // intialize a PDO object
     $pdo = \GeniusFactor\Fibr\Sql\GFSql::getDSN(SQL_SERVER, SQL_USERNAME, SQL_PASSWORD, $db);
     // prep the SQL query to the PDO object
     $result = $pdo->prepare($sql);
     // if parameters are there, add them, otherwise call with no parameters.
     if (!is_null($paramArray) && count($paramArray) > 0) {
         $result->execute($paramArray);
     } else {
         $result->execute();
     }
     return $result;
 }
Example #2
0
 /**
  * [execPDO description]
  * @method execPDO
  * @param  [type]  $sql      [description]
  * @param  [type]  $params   [description]
  * @param  [type]  $database [description]
  * @return [type]            [description]
  */
 function execPDO($sql, $params = null, $database = null)
 {
     if (is_null($database)) {
         return \GeniusFactor\Fibr\Sql\GFSql::execPDO($sql, $params, SQL_DATABASE);
     } else {
         return \GeniusFactor\Fibr\Sql\GFSql::execPDO($sql, $params, $database);
     }
 }
Example #3
0
 /**
  * [getColumnValueAsDateTime description]
  * @method getColumnValueAsDateTime
  * @param  [type]                   $row        [description]
  * @param  [type]                   $columnName [description]
  * @return [type]                               [description]
  */
 function getColumnValueAsDateTime($row, $columnName)
 {
     return \GeniusFactor\FIbr\Sql\GFSql::getColumnValueAsDateTime($row, $columnName);
 }