當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DBConnect::escape_string方法代碼示例

本文整理匯總了PHP中DBConnect::escape_string方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBConnect::escape_string方法的具體用法?PHP DBConnect::escape_string怎麽用?PHP DBConnect::escape_string使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DBConnect的用法示例。


在下文中一共展示了DBConnect::escape_string方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: set_metadata

 /**
  *
  * @param <type> $metadata 
  */
 public function set_metadata($metadata)
 {
     self::validate_content($metadata, DBDataType::DATATYPE_TEXT);
     try
     {
         $metadata = $this->db->escape_string($metadata);
         $this->db->quick_query(
                 "UPDATE ".self::FCORE_FORUM." SET
                     ".self::METADATA."='$metadata' WHERE
                     ".self::FORUM_ID."=$this->forum_id");
         $this->db->commit();
     }
     catch(Exception $e)
     {
         $this->db->rollback();
         throw new DBForumException($e->getMessage());
     }
 }
開發者ID:rexfleischer,項目名稱:web_dev,代碼行數:22,代碼來源:DBForum.php

示例2: consume_identifier

 /**
  *
  * @param <type> $identifier
  * @return <type> 
  */
 private function consume_identifier(&$identifier)
 {
     if (is_null($identifier) || $identifier == "")
     {
         return "";
     }
     if (is_numeric($identifier))
     {
         return " WHERE ".$this->config_map[self::DB_PRI_KEY_NAME]."=".$identifier;
     }
     if (is_string($identifier))
     {
         return " WHERE $identifier";
     }
     if (!is_array($identifier))
     {
         throw new Exception("invalid identifier type");
     }
     ksort($identifier);
     reset($identifier);
     $search = "";
     if (is_numeric(current($identifier)))
     {
         // if the first value is a number, then we can deduce
         // that all of the values are ids of the records this
         // model is manipulating. so, we just get the the
         // id column name for the table and set each one to the
         // value, and or all of them together
         foreach($identifier as $val)
         {
             if (is_numeric($val))
             {
                 if ($search != "")
                 {
                     $search .= " || ";
                 }
                 $search .= $this->config_map[self::DB_PRI_KEY_NAME]."=".$val;
             }
         }
     } 
     else
     {
         // go through each value and build the where clause of the query
         foreach($identifier as $val)
         {
             // check for the type the value is
             if (is_array($val))
             {
                 // check to make sure that all of the required keys are set
                 if (!isset($val[self::ID_KEY]))
                 {
                     throw new Exception(
                             "invalid array identifier: key not set");
                 }
                 if (!isset($val[self::ID_SIGN]))
                 {
                     throw new Exception(
                             "invalid array identifier: sign not set");
                 }
                 if (!isset($val[self::ID_VAL]))
                 {
                     throw new Exception(
                             "invalid array identifier: val not set");
                 }
                 // check to see if 'func' is set... if it isn't, then
                 // we escape the string and wrap it around quotes,
                 // if it is set, then let it string go unaffected
                 $value = "";
                 if (isset($val[self::ID_ESCAPE]))
                 {
                     if ($val[self::ID_ESCAPE])
                     {
                         $value = "'".$this->conn->escape_string(
                                 $val[self::ID_VAL])."'";
                     }
                     else
                     {
                         $value = $val[self::ID_VAL];
                     }
                 }
                 else
                 {
                     $value = "'".$this->conn->escape_string($val[self::ID_VAL])."'";
                 }
                 // include this into the search
                 $search .= $val[self::ID_KEY]." ".$val[self::ID_SIGN]." ".$value;
             }
             else if (is_string($val))
             {
                 $search .= " $val ";
             }
             else
             {
                 throw new Exception("invalid array identifier");
             }
//.........這裏部分代碼省略.........
開發者ID:rexfleischer,項目名稱:web_dev,代碼行數:101,代碼來源:DBFactory.php


注:本文中的DBConnect::escape_string方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。