Database_Core_r1.patch

r1 of proposed patch - ambirex -, 02/03/2009 05:04 pm

Download (2.2 kB)

 
system/libraries/Database.php (working copy)
317 317
	}
318 318

  
319 319
	/**
320
	 * Selects the AVG() of a column name for a database query.
321
	 * 
322
	 * @param   string        $column
323
	 * @param   string        $as
324
	 * @return  Database_Core        This Database object.
325
	 */
326
	public function selectavg($column, $as ='')
327
	{
328
		if( ! empty($as))
329
		{
330
			$as = ' AS ' . $this->driver->escape_str($as);
331
		}
332
		
333
		$column = $this->driver->escape_column($column);
334
		$this->select[] = "AVG($column)" . $as;
335
		
336
		return $this;
337
	}
338

  
339
	/**
340
	 * Selects the MAX() of a column name for a database query.
341
	 * 
342
	 * @param   string        $column
343
	 * @param   string        $as
344
	 * @return  Database_Core        This Database object.
345
	 */
346
	public function selectmax($column, $as ='')
347
	{
348
		if( ! empty($as))
349
		{
350
			$as = ' AS ' . $this->driver->escape_str($as);
351
		}
352
		
353
		$column = $this->driver->escape_column($column);
354
		$this->select[] = "MAX($column)" . $as;
355
		
356
		return $this;
357
	}
358

  
359
	/**
360
	 * Selects the MIN() of a column name for a database query.
361
	 * 
362
	 * @param   string        $column
363
	 * @param   string        $as
364
	 * @return  Database_Core        This Database object.
365
	 */
366
	public function selectmin($column, $as ='')
367
	{
368
		if( ! empty($as))
369
		{
370
			$as = ' AS ' . $this->driver->escape_str($as);
371
		}
372
		
373
		$column = $this->driver->escape_column($column);
374
		$this->select[] = "MIN($column)" . $as;
375
		
376
		return $this;
377
	}
378

  
379
	/**
380
	 * Selects the SUM() of a column name for a database query.
381
	 * 
382
	 * @param   string        $column
383
	 * @param   string        $as
384
	 * @return  Database_Core        This Database object.
385
	 */
386
	public function selectsum($column, $as ='')
387
	{
388
		if( ! empty($as))
389
		{
390
			$as = ' AS ' . $this->driver->escape_str($as);
391
		}
392
		
393
		$column = $this->driver->escape_column($column);
394
		$this->select[] = "SUM($column)" . $as;
395
		
396
		return $this;
397
	}
398

  
399
	/**
320 400
	 * Selects the from table(s) for a database query.
321 401
	 *
322 402
	 * @param   string  string or array of tables to select