Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** Sends given query to MySQL server
- * @param string format
- * @param mixed arguments
- * @return MySQLResult
- */
- static public function query($format) {
- if( !is_resource(self::$connection) ) throw new Exception('Connection to MySQL server has not been established yet');
- $arguments = func_get_args();
- unset($arguments[0]);
- // Renumber arguments array
- $arguments = array_merge($arguments, array());
- // Escape strings
- foreach($arguments as $i=>$arg) {
- if( is_string($arg) ) $arguments[$i] = mysql_escape_string($arg);
- }
- $sql = vsprintf($format, $arguments);
- $result = @mysql_query($sql, self::$connection);
- if( !$result ) throw new Exception(mysql_error(), mysql_errno());
- return new MySQLResult($result);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement