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


PHP FabrikString::safeQuote方法代码示例

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


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

示例1: getFilterValue

 /**
  * Builds an array containing the filters value and condition
  *
  * @param   string  $value      Initial value
  * @param   string  $condition  Initial condition e.g. LIKE, =
  * @param   string  $eval       How the value should be handled
  *
  * @return  array	(value condition)
  */
 public function getFilterValue($value, $condition, $eval)
 {
     $condition = JString::strtolower($condition);
     $this->escapeQueryValue($condition, $value);
     $db = FabrikWorker::getDbo();
     if (is_array($value)) {
         // Ranged search
         list($value, $condition) = $this->getRangedFilterValue($value, $condition);
     } else {
         switch ($condition) {
             case 'notequals':
             case '<>':
                 $condition = "<>";
                 // 2 = sub-query so don't quote
                 $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : $db->q($value);
                 break;
             case 'equals':
             case '=':
                 $condition = "=";
                 $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : $db->q($value);
                 break;
             case 'begins':
             case 'begins with':
                 $condition = "LIKE";
                 $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : $db->q($value . '%');
                 break;
             case 'ends':
             case 'ends with':
                 // @TODO test this with subquery
                 $condition = "LIKE";
                 $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : $db->q('%' . $value);
                 break;
             case 'contains':
             case 'like':
                 // @TODO test this with subquery
                 $condition = "LIKE";
                 $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : $db->q('%' . $value . '%');
                 break;
             case '>':
             case '&gt;':
             case 'greaterthan':
                 $condition = '>';
                 break;
             case '<':
             case '&lt;':
             case 'lessthan':
                 $condition = '<';
                 break;
             case '>=':
             case '&gt;=':
             case 'greaterthanequals':
                 $condition = '>=';
                 break;
             case '<=':
             case '&lt;=':
             case 'lessthanequals':
                 $condition = '<=';
                 break;
             case 'in':
                 $condition = 'IN';
                 $value = FabrikString::safeQuote($value, true);
                 $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : '(' . $value . ')';
                 break;
             case 'not_in':
                 $condition = 'NOT IN';
                 $value = FabrikString::safeQuote($value, true);
                 $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : '(' . $value . ')';
                 break;
         }
         switch ($condition) {
             case '>':
             case '<':
             case '>=':
             case '<=':
                 if ($eval == FABRIKFILTER_QUERY) {
                     $value = '(' . $value . ')';
                 } else {
                     if (!is_numeric($value)) {
                         $value = $db->q($value);
                     }
                 }
                 break;
         }
         // $$$ hugh - if 'noquotes' (3) selected, strip off the quotes again!
         if ($eval == FABRKFILTER_NOQUOTES) {
             // $$$ hugh - darn, this is stripping the ' of the end of things like "select & from foo where bar = '123'"
             $value = JString::ltrim($value, "'");
             $value = JString::rtrim($value, "'");
         }
         if ($condition == '=' && $value == "'_null_'") {
             $condition = " IS NULL ";
//.........这里部分代码省略.........
开发者ID:LGBGit,项目名称:tierno,代码行数:101,代码来源:element.php

示例2: buildQuery

 /**
  * Create the sql query used to get the possible selectable value/labels used to create
  * the drop-down/checkboxes
  *
  * @param   array  $data      data
  * @param   bool   $incWhere  include where
  * @param   array  $opts      query options
  *
  * @return  mixed	JDatabaseQuery or false if query can't be built
  */
 protected function buildQuery($data = array(), $incWhere = true, $opts = array())
 {
     $input = $this->app->input;
     $sig = isset($this->autocomplete_where) ? $this->autocomplete_where . '.' . $incWhere : $incWhere;
     $sig .= '.' . serialize($opts);
     $repeatCounter = FArrayHelper::getValue($opts, 'repeatCounter', 0);
     $db = FabrikWorker::getDbo();
     if (isset($this->sql[$sig])) {
         return $this->sql[$sig];
     }
     $params = $this->getParams();
     $watch = $this->getWatchFullName();
     $whereVal = null;
     $groups = $this->getFormModel()->getGroupsHiarachy();
     $formModel = $this->getFormModel();
     $watchElement = $this->getWatchElement();
     // Test for ajax update
     if ($input->get('fabrik_cascade_ajax_update') == 1) {
         // Allow for multiple values - e.g. when observing a db join rendered as a checkbox
         $whereVal = $input->get('v', array(), 'array');
     } else {
         if (isset($formModel->data) || isset($formModel->formData)) {
             $watchOpts = array('raw' => 1);
             if (isset($formModel->data)) {
                 if ($watchElement->isJoin()) {
                     $id = $watchElement->getFullName(true, false) . '_id';
                     $whereVal = FArrayHelper::getValue($formModel->data, $id);
                 } else {
                     $whereVal = $watchElement->getValue($formModel->data, $repeatCounter, $watchOpts);
                 }
             } else {
                 /*
                  * If we're running onAfterProcess, formData will have short names in it, which means getValue()
                  * won't find the watch element, as it's looking for full names.  So if it exists, use formDataWithTableName.
                  */
                 if (is_array($formModel->formDataWithTableName) && array_key_exists($watch, $formModel->formDataWithTableName)) {
                     $whereVal = $watchElement->getValue($formModel->formDataWithTableName, $repeatCounter, $watchOpts);
                 } else {
                     $whereVal = $watchElement->getValue($formModel->formData, $repeatCounter, $watchOpts);
                 }
             }
             // $$$ hugh - if not set, set to '' to avoid selecting entire table
             if (!isset($whereVal)) {
                 $whereVal = '';
             }
         } else {
             // $$$ hugh - probably rendering table view ...
             $watchRaw = $watch . '_raw';
             if (isset($data[$watchRaw])) {
                 $whereVal = $data[$watchRaw];
             } else {
                 // $$$ hugh ::sigh:: might be coming in via swapLabelsForvalues in pre_process phase
                 // and join array in data will have been flattened.  So try regular element name for watch.
                 $noJoinWatchRaw = $watchElement->getFullName(true, false) . '_raw';
                 if (isset($data[$noJoinWatchRaw])) {
                     $whereVal = $data[$noJoinWatchRaw];
                 } else {
                     // $$$ hugh - if watched element has no value, we have been selecting all rows from CDD table
                     // but should probably select none.
                     // Unless its a cdd autocomplete list filter - seems sensible to populate that with the values matching the search term
                     if ($this->app->input->get('method') !== 'autocomplete_options') {
                         $whereVal = '';
                     }
                 }
             }
         }
     }
     $where = '';
     $whereKey = $params->get('cascadingdropdown_key');
     if (!is_null($whereVal) && $whereKey != '') {
         $whereBits = strstr($whereKey, '___') ? explode('___', $whereKey) : explode('.', $whereKey);
         $whereKey = array_pop($whereBits);
         if (is_array($whereVal)) {
             foreach ($whereVal as &$v) {
                 // Jaanus: Solving bug: imploded arrays when chbx in repeated group
                 if (is_array($v)) {
                     foreach ($v as &$vchild) {
                         $vchild = FabrikString::safeQuote($vchild);
                     }
                     $v = implode(',', $v);
                 } else {
                     $v = FabrikString::safeQuote($v);
                 }
             }
             // Jaanus: if count of where values is 0 or if there are no letters or numbers, only commas in imploded array
             $where .= count($whereVal) == 0 || !preg_match('/\\w/', implode(',', $whereVal)) ? '4 = -4' : $whereKey . ' IN ' . '(' . str_replace(',,', ',\'\',', implode(',', $whereVal)) . ')';
         } else {
             $where .= $whereKey . ' = ' . $db->quote($whereVal);
         }
     }
//.........这里部分代码省略.........
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:101,代码来源:cascadingdropdown.php


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