当前位置: 首页>>代码示例>>PHP>>正文


PHP Datasource::escape方法代码示例

本文整理汇总了PHP中Datasource::escape方法的典型用法代码示例。如果您正苦于以下问题:PHP Datasource::escape方法的具体用法?PHP Datasource::escape怎么用?PHP Datasource::escape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Datasource的用法示例。


在下文中一共展示了Datasource::escape方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sanitize

 public function sanitize($fld, $value)
 {
     if (preg_match("#text\$#", $this->modelStructure[$fld]["type"]) || preg_match("#char\$#", $this->modelStructure[$fld]["type"]) || $this->modelStructure[$fld]["type"] == "enum" || $this->modelStructure[$fld]["type"] == "date" || $this->modelStructure[$fld]["type"] == "timestamp") {
         $value = "'" . Datasource::escape($value) . "'";
     } else {
         if ($this->modelStructure[$fld]["type"] == "tinyint") {
             if (!(intval($value) == 0 || intval($value) == 1)) {
                 SimpleMVCErrors::generalError("Given value ({$value}) is not a valid boolean value");
             }
         } else {
             // Assume to be numeric
             if (!is_numeric($value) && $value != 'NULL') {
                 SimpleMVCErrors::generalError("{$value} given as numeric database input (" . $this->modelSource . ".{$fld})");
             }
         }
     }
     return $value;
 }
开发者ID:almaopen,项目名称:SwissMVC,代码行数:18,代码来源:modelcache.php

示例2: cacheTable

 private function cacheTable($tbName)
 {
     ob_start();
     echo "<?class ModelCache_" . $tbName . " extends ModelCache {\n";
     echo "public function ModelCache_{$tbName}() {\n";
     echo "\t\$this->modelSource = '{$tbName}';\n";
     $rs = Datasource::query("describe " . Datasource::escape($tbName));
     foreach ($rs as $row) {
         echo "\$this->modelStructure['" . $row["Field"] . "'] = array();\n";
         echo "\$this->modelStructure['" . $row["Field"] . "']['is_id'] = " . ($row["Key"] == 'PRI' ? "true" : "false") . ";\n";
         echo "\$this->modelStructure['" . $row["Field"] . "']['type'] = '" . $this->parseType($row["Type"]) . "';\n";
         echo "\$this->modelStructure['" . $row["Field"] . "']['null'] = " . ($row["Null"] == 'NO' ? "false" : "true") . ";\n";
         echo "\$this->modelStructure['" . $row["Field"] . "']['maxlength'] = " . $this->parseLength($row["Type"]) . ";\n";
         echo "\$this->modelStructure['" . $row["Field"] . "']['default'] = " . $this->getDefault($row) . ";\n";
     }
     echo "}\n";
     echo "\n}?>\n";
     $cacheContents = ob_get_contents();
     ob_end_clean();
     $cachePointer = fopen(WEBAPP_ROOT . "/tmp/modelcache/" . md5($tbName) . ".php", "w");
     fwrite($cachePointer, $cacheContents);
     flush($cachePointer);
     fclose($cachePointer);
 }
开发者ID:almaopen,项目名称:SwissMVC,代码行数:24,代码来源:newmodel.php


注:本文中的Datasource::escape方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。