Gdn_SQLDriver::endWhereGroup PHP Method

endWhereGroup() public method

Note: If no items where added to the group then no barackets will appear in the final statement.
public endWhereGroup ( ) : Gdn_SQLDriver
return Gdn_SQLDriver $this
    public function endWhereGroup()
    {
        if ($this->_WhereGroupCount > 0) {
            $WhereCount = count($this->_Wheres);
            if ($this->_OpenWhereGroupCount >= $this->_WhereGroupCount) {
                $this->_OpenWhereGroupCount--;
            } elseif ($WhereCount > 0) {
                $this->_Wheres[$WhereCount - 1] .= ')';
            }
            $this->_WhereGroupCount--;
        }
        return $this;
    }

Usage Example

コード例 #1
0
 /** Add the sql to perform a search.
  *
  * @param Gdn_SQLDriver $Sql
  * @param string $Columns a comma seperated list of columns to search on.
  */
 public function addMatchSql($Sql, $Columns, $LikeRelavenceColumn = '')
 {
     if ($this->_SearchMode == 'like') {
         if ($LikeRelavenceColumn) {
             $Sql->select($LikeRelavenceColumn, '', 'Relavence');
         } else {
             $Sql->select(1, '', 'Relavence');
         }
         $Sql->beginWhereGroup();
         $ColumnsArray = explode(',', $Columns);
         $First = true;
         foreach ($ColumnsArray as $Column) {
             $Column = trim($Column);
             $Param = $this->Parameter();
             if ($First) {
                 $Sql->where("{$Column} like {$Param}", null, false, false);
                 $First = false;
             } else {
                 $Sql->orWhere("{$Column} like {$Param}", null, false, false);
             }
         }
         $Sql->endWhereGroup();
     } else {
         $Boolean = $this->_SearchMode == 'boolean' ? ' in boolean mode' : '';
         $Param = $this->Parameter();
         $Sql->select($Columns, "match(%s) against({$Param}{$Boolean})", 'Relavence');
         $Param = $this->Parameter();
         $Sql->where("match({$Columns}) against ({$Param}{$Boolean})", null, false, false);
     }
 }
All Usage Examples Of Gdn_SQLDriver::endWhereGroup