/**
  * Platform-dependant string escape
  *
  * @param	string
  * @return	string
  */
 protected function _escape_str($str)
 {
     if (function_exists('cubrid_real_escape_string') && (is_resource($this->conn_id) or get_resource_type($this->conn_id) === 'Unknown' && preg_match('/Resource id #/', strval($this->conn_id)))) {
         return cubrid_real_escape_string($str, $this->conn_id);
     }
     return addslashes($str);
 }
Example #2
0
 /**
  * Escape String
  *
  * @access	public
  * @param	string
  * @param	bool	whether or not the string will be used in a LIKE condition
  * @return	string
  */
 function escape_str($str, $like = FALSE)
 {
     if (is_array($str)) {
         foreach ($str as $key => $val) {
             $str[$key] = $this->escape_str($val, $like);
         }
         return $str;
     }
     if (function_exists('cubrid_real_escape_string') and is_resource($this->conn_id)) {
         $str = cubrid_real_escape_string($str, $this->conn_id);
     } else {
         $str = addslashes($str);
     }
     // escape LIKE condition wildcards
     if ($like === TRUE) {
         $str = str_replace(array('%', '_'), array('\\%', '\\_'), $str);
     }
     return $str;
 }
Example #3
0
 /**
  * Platform-dependant string escape
  *
  * @param	string
  * @return	string
  */
 protected function _escape_str($str)
 {
     return cubrid_real_escape_string($str, $this->conn_id);
 }
Example #4
0
 public function realEscapeString($data = '')
 {
     if (empty($this->connect)) {
         return false;
     }
     return cubrid_real_escape_string($data, $this->connect);
 }
Example #5
0
 /**
  * Escape String
  *
  * @param	string
  * @param	bool	whether or not the string will be used in a LIKE condition
  * @return	string
  */
 public function escape_str($str, $like = FALSE)
 {
     if (is_array($str)) {
         foreach ($str as $key => $val) {
             $str[$key] = $this->escape_str($val, $like);
         }
         return $str;
     }
     if (function_exists('cubrid_real_escape_string') && (is_resource($this->conn_id) or get_resource_type($this->conn_id) === 'Unknown' && preg_match('/Resource id #/', strval($this->conn_id)))) {
         $str = cubrid_real_escape_string($str, $this->conn_id);
     } else {
         $str = addslashes($str);
     }
     // escape LIKE condition wildcards
     if ($like === TRUE) {
         return str_replace(array('%', '_'), array('\\%', '\\_'), $str);
     }
     return $str;
 }
Example #6
0
 /**
  * Escape all unescaped string
  *
  * @param string $string
  * @return void
  */
 public function escape($string)
 {
     if (is_null($this->link)) {
         $this->init();
     }
     if (function_exists('cubrid_real_escape_string')) {
         $string = cubrid_real_escape_string($string, $this->link);
     } else {
         $string = addslashes($string);
     }
     return $string;
 }
Example #7
0
 function escape($str)
 {
     // If there is no existing database connection then try to connect
     if (!isset($this->dbh) || !$this->dbh) {
         $this->connect($this->dbuser, $this->dbpassword, $this->dbhost);
     }
     return cubrid_real_escape_string(stripslashes($str));
 }
Example #8
0
 /**
  * @group arnia-wrong-parameters-count
  */
 public function testCubridRealEscapeString2()
 {
     if (OUTPUT_FUNCTION_NAME == true) {
         echo "\r\nRunning: " . __FUNCTION__ . " = ";
     }
     try {
         $this->sql = "SELECT \\abc\\, 'ds' FROM db_root";
         $escaped_sql = cubrid_real_escape_string();
         $this->assertTrue(FALSE, "Expected Exception not thrown.");
     } catch (Exception $e) {
         //echo $e->getMessage();
         $this->assertEquals(0, cubrid_error_code());
         $this->assertEquals(0, cubrid_error_code_facility());
         $this->assertEquals('', cubrid_error_msg());
     }
 }
Example #9
0
function sql_escape_string($string, $link = null)
{
    if (isset($link)) {
        $string = cubrid_real_escape_string($string, $link);
    }
    if (!isset($link)) {
        $string = cubrid_real_escape_string($string);
    }
    if ($string === false) {
        output_error("SQL Error: " . sql_error(), E_USER_ERROR);
        return false;
    }
    return $string;
}