Nooku Framework is an open source project powered by Assembla

Assembla offers free public and private SVN/Git repositories and project hosting with bug/issue tracking and collaboration tools.

nooku-framework

Commit 1975

User picture
  • Author: johanjanssens
  • 2010-05-06 05:47 (almost 4 years ago)

re #3 : Small change in the where() function to all WHERE clauses that don't contain a contrain and value but only a SQL function.

Files Affected

 
19741975
238
    /**
238
    /**
239
     * Built the where clause of the query
239
     * Built the where clause of the query
240
     *
240
     *
241
     * @param   string             The name of the property the constraint applies too
241
     * @param   string             The name of the property the constraint applies too, or a SQL function or statement
242
     * @param    string          The comparison used for the constraint
242
     * @param    string          The comparison used for the constraint
243
     * @param    string|array    The value compared to the property value using the constraint
243
     * @param    string|array    The value compared to the property value using the constraint
244
     * @param    string            The where condition, defaults to 'AND'
244
     * @param    string            The where condition, defaults to 'AND'
245
     * @return     KDatabaseQuery
245
     * @return     KDatabaseQuery
246
     */
246
     */
247
    public function where( $property, $constraint, $value = null, $condition = 'AND' )
247
    public function where( $property, $constraint = null, $value = null, $condition = 'AND' )
248
    {
248
    {
249
        if(empty($property)) {
249
        if(empty($property)) {
250
            return $this;
250
            return $this;
251
        }
251
        }
252
 
252
 
253
        $constraint    = strtoupper($constraint);
 
 
254
        $condition    = strtoupper($condition);
 
 
255
        
 
 
256
        // Apply quotes to the property name
253
        // Apply quotes to the property name
257
        $property = $this->_adapter->quoteName($property);
254
        $where = $this->_adapter->quoteName($property);
258
 
255
 
259
        // Apply quotes to the value
256
        if(isset($constraint) && isset($value)) 
260
        $value    = $this->_adapter->quoteValue($value);
257
        {
 
 
258
            $constraint    = strtoupper($constraint);
 
 
259
            $condition    = strtoupper($condition);
261
 
260
 
262
           //Create the where clause
261
            // Apply quotes to the value
263
        if(in_array($constraint, array('IN', 'NOT IN'))) {
262
            $value = $this->_adapter->quoteValue($value);
264
            $value = ' ( '.$value. ' ) ';
 
 
265
        } 
 
 
266
 
263
 
267
        $where = $property.' '.$constraint.' '.$value;
264
               //Create the where clause
268
 
265
            if(in_array($constraint, array('IN', 'NOT IN'))) {
 
 
266
                $value = ' ( '.$value. ' ) ';
 
 
267
            }     
 
 
268
            
 
 
269
            $where = $where.' '.$constraint.' '.$value;
 
 
270
        }
 
 
271
            
269
        //Prepend the condition
272
        //Prepend the condition
270
        if(count($this->where)) {
273
        if(count($this->where)) {
271
            $where = $condition .' '. $where;
274
            $where = $condition .' '. $where;