[ Index ]

PHP Cross Reference of Joomla 2.5.4 DE

title

Body

[close]

/libraries/joomla/database/ -> query.php (summary)

(no description)

Copyright: Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
License: GNU General Public License version 2 or later; see LICENSE
File Size: 1203 lines (26 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

JDatabaseQueryElement:: (39 methods):
  __construct()
  __toString()
  append()
  getElements()
  __clone()
  __call()
  __construct()
  __toString()
  __get()
  castAsChar()
  charLength()
  clear()
  columns()
  concatenate()
  currentTimestamp()
  dateFormat()
  dump()
  delete()
  escape()
  from()
  group()
  having()
  innerJoin()
  insert()
  join()
  leftJoin()
  length()
  nullDate()
  order()
  outerJoin()
  quote()
  quoteName()
  rightJoin()
  select()
  set()
  update()
  values()
  where()
  __clone()


Class: JDatabaseQueryElement  - X-Ref

Query Element Class.

__construct($name, $elements, $glue = ',')   X-Ref
Constructor.

param: string  $name      The name of the element.
param: mixed   $elements  String or array.
param: string  $glue      The glue for elements.

__toString()   X-Ref
Magic function to convert the query element to a string.

return: string

append($elements)   X-Ref
Appends element parts to the internal list.

param: mixed  $elements  String or array.
return: void

getElements()   X-Ref
Gets the elements of this element.

return: string

__clone()   X-Ref
Method to provide deep copy support to nested objects and arrays
when cloning.

return: void

__call($method, $args)   X-Ref
Magic method to provide method alias support for quote() and quoteName().

param: string  $method  The called method.
param: array   $args    The array of arguments passed to the method.
return: string  The aliased method's return value or null.

__construct(JDatabase $db = null)   X-Ref
Class constructor.

param: JDatabase  $db  The database connector resource.

__toString()   X-Ref
Magic function to convert the query to a string.

return: string    The completed query.

__get($name)   X-Ref
Magic function to get protected variable value

param: string  $name  The name of the variable.
return: mixed

castAsChar($value)   X-Ref
Casts a value to a char.

Ensure that the value is properly quoted before passing to the method.

Usage:
$query->select($query->castAsChar('a'));

param: string  $value  The value to cast as a char.
return: string  Returns the cast value.

charLength($field)   X-Ref
Gets the number of characters in a string.

Note, use 'length' to find the number of bytes in a string.

Usage:
$query->select($query->charLength('a'));

param: string  $field  A value.
return: string  The required char length call.

clear($clause = null)   X-Ref
Clear data from the query or a specific clause of the query.

param: string  $clause  Optionally, the name of the clause to clear, or nothing to clear the whole query.
return: JDatabaseQuery  Returns this object to allow chaining.

columns($columns)   X-Ref
Adds a column, or array of column names that would be used for an INSERT INTO statement.

param: mixed  $columns  A column name, or array of column names.
return: JDatabaseQuery  Returns this object to allow chaining.

concatenate($values, $separator = null)   X-Ref
Concatenates an array of column names or values.

Usage:
$query->select($query->concatenate(array('a', 'b')));

param: array   $values     An array of values to concatenate.
param: string  $separator  As separator to place between each value.
return: string  The concatenated values.

currentTimestamp()   X-Ref
Gets the current date and time.

Usage:
$query->where('published_up < '.$query->currentTimestamp());

return: string

dateFormat()   X-Ref
Returns a PHP date() function compliant date format for the database driver.

This method is provided for use where the query object is passed to a function for modification.
If you have direct access to the database object, it is recommended you use the getDateFormat method directly.

return: string  The format string.

dump()   X-Ref
Creates a formatted dump of the query for debugging purposes.

Usage:
echo $query->dump();

return: string

delete($table = null)   X-Ref
Add a table name to the DELETE clause of the query.

Note that you must not mix insert, update, delete and select method calls when building a query.

Usage:
$query->delete('#__a')->where('id = 1');

param: string  $table  The name of the table to delete from.
return: JDatabaseQuery  Returns this object to allow chaining.

escape($text, $extra = false)   X-Ref
Method to escape a string for usage in an SQL statement.

This method is provided for use where the query object is passed to a function for modification.
If you have direct access to the database object, it is recommended you use the escape method directly.

Note that 'e' is an alias for this method as it is in JDatabase.

param: string   $text   The string to be escaped.
param: boolean  $extra  Optional parameter to provide extra escaping.
return: string  The escaped string.

from($tables)   X-Ref
Add a table to the FROM clause of the query.

Note that while an array of tables can be provided, it is recommended you use explicit joins.

Usage:
$query->select('*')->from('#__a');

param: mixed  $tables  A string or array of table names.
return: JDatabaseQuery  Returns this object to allow chaining.

group($columns)   X-Ref
Add a grouping column to the GROUP clause of the query.

Usage:
$query->group('id');

param: mixed  $columns  A string or array of ordering columns.
return: JDatabaseQuery  Returns this object to allow chaining.

having($conditions, $glue = 'AND')   X-Ref
A conditions to the HAVING clause of the query.

Usage:
$query->group('id')->having('COUNT(id) > 5');

param: mixed   $conditions  A string or array of columns.
param: string  $glue        The glue by which to join the conditions. Defaults to AND.
return: JDatabaseQuery  Returns this object to allow chaining.

innerJoin($condition)   X-Ref
Add an INNER JOIN clause to the query.

Usage:
$query->innerJoin('b ON b.id = a.id')->innerJoin('c ON c.id = b.id');

param: string  $condition  The join condition.
return: JDatabaseQuery  Returns this object to allow chaining.

insert($table, $incrementField=false)   X-Ref
Add a table name to the INSERT clause of the query.

Note that you must not mix insert, update, delete and select method calls when building a query.

Usage:
$query->insert('#__a')->set('id = 1');
$query->insert('#__a)->columns('id, title')->values('1,2')->values->('3,4');
$query->insert('#__a)->columns('id, title')->values(array('1,2', '3,4'));

param: mixed    $table           The name of the table to insert data into.
param: boolean  $incrementField  The name of the field to auto increment.
return: JDatabaseQuery  Returns this object to allow chaining.

join($type, $conditions)   X-Ref
Add a JOIN clause to the query.

Usage:
$query->join('INNER', 'b ON b.id = a.id);

param: string  $type        The type of join. This string is prepended to the JOIN keyword.
param: string  $conditions  A string or array of conditions.
return: JDatabaseQuery  Returns this object to allow chaining.

leftJoin($condition)   X-Ref
Add a LEFT JOIN clause to the query.

Usage:
$query->leftJoin('b ON b.id = a.id')->leftJoin('c ON c.id = b.id');

param: string  $condition  The join condition.
return: JDatabaseQuery  Returns this object to allow chaining.

length($value)   X-Ref
Get the length of a string in bytes.

Note, use 'charLength' to find the number of characters in a string.

Usage:
query->where($query->length('a').' > 3');

param: string  $value  The string to measure.
return: int

nullDate($quoted = true)   X-Ref
Get the null or zero representation of a timestamp for the database driver.

This method is provided for use where the query object is passed to a function for modification.
If you have direct access to the database object, it is recommended you use the nullDate method directly.

Usage:
$query->where('modified_date <> '.$query->nullDate());

param: boolean  $quoted  Optionally wraps the null date in database quotes (true by default).
return: string  Null or zero representation of a timestamp.

order($columns)   X-Ref
Add a ordering column to the ORDER clause of the query.

Usage:
$query->order('foo')->order('bar');
$query->order(array('foo','bar'));

param: mixed  $columns  A string or array of ordering columns.
return: JDatabaseQuery  Returns this object to allow chaining.

outerJoin($condition)   X-Ref
Add an OUTER JOIN clause to the query.

Usage:
$query->outerJoin('b ON b.id = a.id')->outerJoin('c ON c.id = b.id');

param: string  $condition  The join condition.
return: JDatabaseQuery  Returns this object to allow chaining.

quote($text, $escape = true)   X-Ref
Method to quote and optionally escape a string to database requirements for insertion into the database.

This method is provided for use where the query object is passed to a function for modification.
If you have direct access to the database object, it is recommended you use the quote method directly.

Note that 'q' is an alias for this method as it is in JDatabase.

Usage:
$query->quote('fulltext');
$query->q('fulltext');

param: string   $text    The string to quote.
param: boolean  $escape  True to escape the string, false to leave it unchanged.
return: string  The quoted input string.

quoteName($name)   X-Ref
Wrap an SQL statement identifier name such as column, table or database names in quotes to prevent injection
risks and reserved word conflicts.

This method is provided for use where the query object is passed to a function for modification.
If you have direct access to the database object, it is recommended you use the quoteName method directly.

Note that 'qn' is an alias for this method as it is in JDatabase.

Usage:
$query->quoteName('#__a');
$query->qn('#__a');

param: string  $name  The identifier name to wrap in quotes.
return: string  The quote wrapped name.

rightJoin($condition)   X-Ref
Add a RIGHT JOIN clause to the query.

Usage:
$query->rightJoin('b ON b.id = a.id')->rightJoin('c ON c.id = b.id');

param: string  $condition  The join condition.
return: JDatabaseQuery  Returns this object to allow chaining.

select($columns)   X-Ref
Add a single column, or array of columns to the SELECT clause of the query.

Note that you must not mix insert, update, delete and select method calls when building a query.
The select method can, however, be called multiple times in the same query.

Usage:
$query->select('a.*')->select('b.id');
$query->select(array('a.*', 'b.id'));

param: mixed  $columns  A string or an array of field names.
return: JDatabaseQuery  Returns this object to allow chaining.

set($conditions, $glue = ',')   X-Ref
Add a single condition string, or an array of strings to the SET clause of the query.

Usage:
$query->set('a = 1')->set('b = 2');
$query->set(array('a = 1', 'b = 2');

param: mixed   $conditions  A string or array of string conditions.
param: string  $glue        The glue by which to join the condition strings. Defaults to ,.
return: JDatabaseQuery  Returns this object to allow chaining.

update($table)   X-Ref
Add a table name to the UPDATE clause of the query.

Note that you must not mix insert, update, delete and select method calls when building a query.

Usage:
$query->update('#__foo')->set(...);

param: string  $table  A table to update.
return: JDatabaseQuery  Returns this object to allow chaining.

values($values)   X-Ref
Adds a tuple, or array of tuples that would be used as values for an INSERT INTO statement.

Usage:
$query->values('1,2,3')->values('4,5,6');
$query->values(array('1,2,3', '4,5,6'));

param: string  $values  A single tuple, or array of tuples.
return: JDatabaseQuery  Returns this object to allow chaining.

where($conditions, $glue = 'AND')   X-Ref
Add a single condition, or an array of conditions to the WHERE clause of the query.

Usage:
$query->where('a = 1')->where('b = 2');
$query->where(array('a = 1', 'b = 2'));

param: mixed   $conditions  A string or array of where conditions.
param: string  $glue        The glue by which to join the conditions. Defaults to AND.
return: JDatabaseQuery  Returns this object to allow chaining.

__clone()   X-Ref
Method to provide deep copy support to nested objects and
arrays when cloning.

return: void



Generated: Tue Apr 3 11:40:28 2012 Cross-referenced by PHPXref 0.7.1