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


PHP PHPWS_DB::inDatabase方法代码示例

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


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

示例1: addWhere

 public function addWhere($column, $value = null, $operator = null, $conj = null, $group = null, $join = false)
 {
     PHPWS_DB::touchDB();
     $where = new PHPWS_DB_Where();
     $where->setJoin($join);
     $operator = strtoupper($operator);
     // If passed in value was an array, loop over the array and call this method once for each column name
     if (is_array($column)) {
         foreach ($column as $new_column => $new_value) {
             $result = $this->addWhere($new_column, $new_value, $operator, $conj, $group);
             if (PHPWS_Error::isError($result)) {
                 return $result;
             }
         }
         return true;
     } else {
         // Single column name passed in, check column name
         if (!PHPWS_DB::allowed($column) || preg_match('[^\\w\\.]', $column)) {
             return PHPWS_Error::get(PHPWS_DB_BAD_COL_NAME, 'core', 'PHPWS_DB::addWhere', $column);
         }
     }
     // If non-empty array of values passed in for this column name
     if (is_array($value) && !empty($value)) {
         if (!empty($operator) && $operator != 'IN' && $operator != 'NOT IN' && $operator != 'BETWEEN' && $operator != 'NOT BETWEEN') {
             $search_in = true;
         } else {
             if (empty($operator)) {
                 $operator = 'IN';
             }
             $search_in = false;
         }
         foreach ($value as $newVal) {
             if ($search_in) {
                 $result = $this->addWhere($column, $newVal, $operator, $conj, $group);
                 if (PHPWS_Error::isError($result)) {
                     return $result;
                 }
             } else {
                 $newVal = $GLOBALS['PHPWS_DB']['connection']->escape($newVal);
                 $new_value_list[] = $newVal;
             }
         }
         if (!$search_in && isset($new_value_list)) {
             $value =& $new_value_list;
         } else {
             return true;
         }
     } else {
         // Single value passed in
         if (is_null($value) || is_string($value) && strtoupper($value) == 'NULL') {
             if (empty($operator) || $operator != 'IS NOT' && $operator != '!=') {
                 $operator = 'IS';
             } else {
                 $operator = 'IS NOT';
             }
             $value = 'NULL';
         } else {
             $value = $GLOBALS['PHPWS_DB']['connection']->escape($value);
         }
     }
     $source_table = $this->getSourceTable();
     //$source_table = $this->tables[0];
     if (is_string($column)) {
         if (substr_count($column, '.') == 1) {
             list($join_table, $join_column) = explode('.', $column);
             if (isset($this->table_as[$join_table])) {
                 $source_table = $join_table;
                 $column =& $join_column;
             } elseif (PHPWS_DB::inDatabase($join_table, $join_column)) {
                 $source_table = $join_table;
                 /***
                  * Commented out because this is trying to work too hard.
                  * If you (as a developer) haven't selected from or joined
                  * the table you're trying to add a 'WHERE' expression for,
                  * then I can't help you. The query will fail, and you'll figure it out.
                  */
                 //$this->addTable($join_table);
             }
         }
     }
     //TODO what do we do if $column isn't a string?
     $where->setColumn($column);
     $where->setTable($source_table);
     if (is_string($value)) {
         if (substr_count($value, '.') == 1) {
             list($join_table, $join_column) = explode('.', $value);
             if (isset($this->table_as[$join_table])) {
                 $where->setJoin(true);
             } elseif ($this->inDatabase($join_table, $join_column)) {
                 $where->setJoin(true);
                 $this->addTable($join_table);
             }
         }
     }
     $where->setValue($value);
     $where->setConj($conj);
     $where->setOperator($operator);
     if (isset($group)) {
         $this->where[$group]['values'][] = $where;
     } else {
//.........这里部分代码省略.........
开发者ID:jeffrafter,项目名称:InternshipInventory,代码行数:101,代码来源:SubselectDatabase.php

示例2: addWhere

 public function addWhere($column, $value = null, $operator = null, $conj = null, $group = null, $join = false)
 {
     PHPWS_DB::touchDB();
     $where = new PHPWS_DB_Where();
     $where->setJoin($join);
     $operator = strtoupper($operator);
     if (is_array($column)) {
         foreach ($column as $new_column => $new_value) {
             $result = $this->addWhere($new_column, $new_value, $operator, $conj, $group);
             if (PHPWS_Error::isError($result)) {
                 return $result;
             }
         }
         return true;
     } else {
         if (!PHPWS_DB::allowed($column) || preg_match('[^\\w\\.]', $column)) {
             return PHPWS_Error::get(PHPWS_DB_BAD_COL_NAME, 'core', 'PHPWS_DB::addWhere', $column);
         }
     }
     if (is_array($value) && !empty($value)) {
         if (!empty($operator) && $operator != 'IN' && $operator != 'NOT IN' && $operator != 'BETWEEN' && $operator != 'NOT BETWEEN') {
             $search_in = true;
         } else {
             if (empty($operator)) {
                 $operator = 'IN';
             }
             $search_in = false;
         }
         foreach ($value as $newVal) {
             if ($search_in) {
                 $result = $this->addWhere($column, $newVal, $operator, $conj, $group);
                 if (PHPWS_Error::isError($result)) {
                     return $result;
                 }
             } else {
                 $newVal = $GLOBALS['PHPWS_DB']['connection']->escape($newVal);
                 $new_value_list[] = $newVal;
             }
         }
         if (!$search_in && isset($new_value_list)) {
             $value =& $new_value_list;
         } else {
             return true;
         }
     } else {
         if (is_null($value) || is_string($value) && strtoupper($value) == 'NULL') {
             if (empty($operator) || $operator != 'IS NOT' && $operator != '!=') {
                 $operator = 'IS';
             } else {
                 $operator = 'IS NOT';
             }
             $value = 'NULL';
         } else {
             $value = $GLOBALS['PHPWS_DB']['connection']->escape($value);
         }
     }
     $source_table = $this->tables[0];
     if (is_string($column)) {
         if (substr_count($column, '.') == 1) {
             list($join_table, $join_column) = explode('.', $column);
             if (isset($this->table_as[$join_table])) {
                 $source_table = $join_table;
                 $column =& $join_column;
             } elseif (PHPWS_DB::inDatabase($join_table, $join_column)) {
                 $column =& $join_column;
                 $source_table = $join_table;
                 $this->addTable($join_table);
             }
         }
     }
     $where->setColumn($column);
     $where->setTable($source_table);
     if (is_string($value)) {
         if (substr_count($value, '.') == 1) {
             list($join_table, $join_column) = explode('.', $value);
             if (!empty($this->table_as) && isset($this->table_as[$join_table])) {
                 $where->setJoin(true);
             } else {
                 if ($this->inDatabase($join_table, $join_column)) {
                     $where->setJoin(true);
                     $this->addTable($join_table);
                 }
             }
         }
     }
     $where->setValue($value);
     $where->setConj($conj);
     $where->setOperator($operator);
     if (isset($group)) {
         $this->where[$group]['values'][] = $where;
     } else {
         $this->where[0]['values'][] = $where;
     }
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:94,代码来源:PHPWS_DB.php


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