当前位置: 首页>>代码示例>>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;未经允许,请勿转载。