TYPO3 API  SVNRelease
Public Member Functions | Public Attributes | Protected Member Functions
t3lib_DB Class Reference
Inheritance diagram for t3lib_DB:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 exec_INSERTquery ($table, $fields_values, $no_quote_fields=FALSE)
 exec_INSERTmultipleRows ($table, array $fields, array $rows, $no_quote_fields=FALSE)
 exec_UPDATEquery ($table, $where, $fields_values, $no_quote_fields=FALSE)
 exec_DELETEquery ($table, $where)
 exec_SELECTquery ($select_fields, $from_table, $where_clause, $groupBy= '', $orderBy= '', $limit= '')
 exec_SELECT_mm_query ($select, $local_table, $mm_table, $foreign_table, $whereClause= '', $groupBy= '', $orderBy= '', $limit= '')
 exec_SELECT_queryArray ($queryParts)
 exec_SELECTgetRows ($select_fields, $from_table, $where_clause, $groupBy= '', $orderBy= '', $limit= '', $uidIndexField= '')
 exec_SELECTgetSingleRow ($select_fields, $from_table, $where_clause, $groupBy= '', $orderBy= '', $numIndex=FALSE)
 exec_SELECTcountRows ($field, $table, $where= '')
 exec_TRUNCATEquery ($table)
 INSERTquery ($table, $fields_values, $no_quote_fields=FALSE)
 INSERTmultipleRows ($table, array $fields, array $rows, $no_quote_fields=FALSE)
 UPDATEquery ($table, $where, $fields_values, $no_quote_fields=FALSE)
 DELETEquery ($table, $where)
 SELECTquery ($select_fields, $from_table, $where_clause, $groupBy= '', $orderBy= '', $limit= '')
 SELECTsubquery ($select_fields, $from_table, $where_clause)
 TRUNCATEquery ($table)
 listQuery ($field, $value, $table)
 searchQuery ($searchWords, $fields, $table)
 prepare_SELECTquery ($select_fields, $from_table, $where_clause, $groupBy= '', $orderBy= '', $limit= '', array $input_parameters=array())
 prepare_SELECTqueryArray (array $queryParts, array $input_parameters=array())
 exec_PREPAREDquery ($query, array $queryComponents)
 fullQuoteStr ($str, $table)
 fullQuoteArray ($arr, $table, $noQuote=FALSE)
 quoteStr ($str, $table)
 escapeStrForLike ($str, $table)
 cleanIntArray ($arr)
 cleanIntList ($list)
 stripOrderBy ($str)
 stripGroupBy ($str)
 splitGroupOrderLimit ($str)
 sql_query ($query)
 sql_error ()
 sql_errno ()
 sql_num_rows ($res)
 sql_fetch_assoc ($res)
 sql_fetch_row ($res)
 sql_free_result ($res)
 sql_insert_id ()
 sql_affected_rows ()
 sql_data_seek ($res, $seek)
 sql_field_type ($res, $pointer)
 sql_pconnect ($TYPO3_db_host, $TYPO3_db_username, $TYPO3_db_password)
 sql_select_db ($TYPO3_db)
 admin_get_dbs ()
 admin_get_tables ()
 admin_get_fields ($tableName)
 admin_get_keys ($tableName)
 admin_get_charsets ()
 admin_query ($query)
 connectDB ($host=TYPO3_db_host, $user=TYPO3_db_username, $password=TYPO3_db_password, $db=TYPO3_db)
 isConnected ()
 debug ($func, $query= '')
 debug_check_recordset ($res)

Public Attributes

 $debugOutput = FALSE
 $debug_lastBuiltQuery = ''
 $store_lastBuiltQuery = FALSE
 $explainOutput = 0
 $link = FALSE
 $default_charset = 'utf8'

Protected Member Functions

 setSqlMode ()
 explain ($query, $from_table, $row_count)

Detailed Description

Definition at line 130 of file class.t3lib_db.php.


Member Function Documentation

t3lib_DB::admin_get_charsets ( )

Returns information about the character sets supported by the current DBM This function is important not only for the Install Tool but probably for DBALs as well since they might need to look up table specific information in order to construct correct queries. In such cases this information should probably be cached for quick delivery.

This is used by the Install Tool to convert tables tables with non-UTF8 charsets Use in Install Tool only!

Returns:
array Array with Charset as key and an array of "Charset", "Description", "Default collation", "Maxlen" as values

Reimplemented in ux_t3lib_DB.

Definition at line 1321 of file class.t3lib_db.php.

t3lib_DB::admin_get_dbs ( )

Listing databases from current MySQL connection. NOTICE: It WILL try to select those databases and thus break selection of current database. This is only used as a service function in the (1-2-3 process) of the Install Tool. In any case a lookup should be done in the _DEFAULT handler DBMS then. Use in Install Tool only! Usage count/core: 1

Returns:
array Each entry represents a database name

Reimplemented in ux_t3lib_DB.

Definition at line 1231 of file class.t3lib_db.php.

t3lib_DB::admin_get_fields ( tableName)

Returns information about each field in the $table (quering the DBMS) In a DBAL this should look up the right handler for the table and return compatible information This function is important not only for the Install Tool but probably for DBALs as well since they might need to look up table specific information in order to construct correct queries. In such cases this information should probably be cached for quick delivery.

Parameters:
stringTable name
Returns:
array Field information in an associative array with fieldname => field row

Reimplemented in ux_t3lib_DB.

Definition at line 1276 of file class.t3lib_db.php.

t3lib_DB::admin_get_keys ( tableName)

Returns information about each index key in the $table (quering the DBMS) In a DBAL this should look up the right handler for the table and return compatible information

Parameters:
stringTable name
Returns:
array Key information in a numeric array

Reimplemented in ux_t3lib_DB.

Definition at line 1296 of file class.t3lib_db.php.

t3lib_DB::admin_get_tables ( )

Returns the list of tables from the default database, TYPO3_db (quering the DBMS) In a DBAL this method should 1) look up all tables from the DBMS of the _DEFAULT handler and then 2) add all tables *configured* to be managed by other handlers Usage count/core: 2

Returns:
array Array with tablenames as key and arrays with status information as value

Reimplemented in ux_t3lib_DB.

Definition at line 1250 of file class.t3lib_db.php.

t3lib_DB::admin_query ( query)

mysql() wrapper function, used by the Install Tool and EM for all queries regarding management of the database! Usage count/core: 10

Parameters:
stringQuery to execute
Returns:
pointer Result pointer

Reimplemented in ux_t3lib_DB.

Definition at line 1343 of file class.t3lib_db.php.

t3lib_DB::cleanIntArray ( arr)

Will convert all values in the one-dimensional array to integers. Useful when you want to make sure an array contains only integers before imploding them in a select-list. Usage count/core: 7

Parameters:
arrayArray with values
Returns:
array The input array with all values passed through intval()
See also:
cleanIntList()

Definition at line 836 of file class.t3lib_db.php.

t3lib_DB::cleanIntList ( list)

Will force all entries in the input comma list to integers Useful when you want to make sure a commalist of supposed integers really contain only integers; You want to know that when you don't trust content that could go into an SQL statement. Usage count/core: 6

Parameters:
stringList of comma-separated values which should be integers
Returns:
string The input list but with every value passed through intval()
See also:
cleanIntArray()

Definition at line 852 of file class.t3lib_db.php.

References t3lib_div\intExplode().

t3lib_DB::connectDB ( host = TYPO3_db_host,
user = TYPO3_db_username,
password = TYPO3_db_password,
db = TYPO3_db 
)

Connects to database for TYPO3 sites:

Parameters:
string$host
string$user
string$password
string$db
Returns:
void

Definition at line 1367 of file class.t3lib_db.php.

t3lib_DB::debug ( func,
query = '' 
)
t3lib_DB::debug_check_recordset ( res)

Checks if recordset is valid and writes debugging inormation into devLog if not.

Parameters:
resource$resRecordset
Returns:
boolean false if recordset is not valid

Definition at line 1434 of file class.t3lib_db.php.

t3lib_DB::DELETEquery ( table,
where 
)

Creates a DELETE SQL-statement for $table where $where-clause Usage count/core: 3

Parameters:
stringSee exec_DELETEquery()
stringSee exec_DELETEquery()
Returns:
string Full SQL query for DELETE

Reimplemented in ux_t3lib_DB.

Definition at line 541 of file class.t3lib_db.php.

References $query, and debugOutput.

Referenced by exec_DELETEquery().

t3lib_DB::escapeStrForLike ( str,
table 
)

Escaping values for SQL LIKE statements.

Parameters:
stringInput string
stringTable name for which to escape string. Just enter the table that the field-value is selected from (and any DBAL will look up which handler to use and then how to quote the string!).
Returns:
string Output string; % and _ will be escaped with \ (or otherwise based on DBAL handler)
See also:
quoteStr()

Definition at line 823 of file class.t3lib_db.php.

Referenced by ux_t3lib_DB\_quoteWhereClause().

t3lib_DB::exec_DELETEquery ( table,
where 
)

Creates and executes a DELETE SQL-statement for $table where $where-clause Usage count/core: 40

Parameters:
stringDatabase tablename
stringWHERE clause, eg. "uid=1". NOTICE: You must escape values in this argument with $this->fullQuoteStr() yourself!
Returns:
pointer MySQL result pointer / DBAL object

Reimplemented in ux_t3lib_DB.

Definition at line 221 of file class.t3lib_db.php.

References $res, debug(), debugOutput, and DELETEquery().

t3lib_DB::exec_INSERTmultipleRows ( table,
array $  fields,
array $  rows,
no_quote_fields = FALSE 
)

Creates and executes an INSERT SQL-statement for $table with multiple rows.

Parameters:
stringTable name
arrayField names
arrayTable rows. Each row should be an array with field values mapping to $fields
string/arraySee fullQuoteArray()
Returns:
pointer MySQL result pointer / DBAL object

Reimplemented in ux_t3lib_DB.

Definition at line 186 of file class.t3lib_db.php.

References $res, debug(), debugOutput, and INSERTmultipleRows().

t3lib_DB::exec_INSERTquery ( table,
fields_values,
no_quote_fields = FALSE 
)

Creates and executes an INSERT SQL-statement for $table from the array with field/value pairs $fields_values. Using this function specifically allows us to handle BLOB and CLOB fields depending on DB Usage count/core: 47

Parameters:
stringTable name
arrayField values as key=>value pairs. Values will be escaped internally. Typically you would fill an array like "$insertFields" with 'fieldname'=>'value' and pass it to this function as argument.
string/arraySee fullQuoteArray()
Returns:
pointer MySQL result pointer / DBAL object

Reimplemented in ux_t3lib_DB.

Definition at line 169 of file class.t3lib_db.php.

References $res, debug(), debugOutput, and INSERTquery().

t3lib_DB::exec_PREPAREDquery ( query,
array $  queryComponents 
)

Executes a prepared query. This method may only be called by t3lib_db_PreparedStatement.

Parameters:
string$queryThe query to execute
array$queryComponentsThe components of the query to execute
Returns:
pointer MySQL result pointer / DBAL object private

Reimplemented in ux_t3lib_DB.

Definition at line 741 of file class.t3lib_db.php.

References $query, $res, debug(), and debugOutput.

t3lib_DB::exec_SELECT_mm_query ( select,
local_table,
mm_table,
foreign_table,
whereClause = '',
groupBy = '',
orderBy = '',
limit = '' 
)

Creates and executes a SELECT query, selecting fields ($select) from two/three tables joined Use $mm_table together with $local_table or $foreign_table to select over two tables. Or use all three tables to select the full MM-relation. The JOIN is done with [$local_table].uid <--> [$mm_table].uid_local / [$mm_table].uid_foreign <--> [$foreign_table].uid The function is very useful for selecting MM-relations between tables adhering to the MM-format used by TCE (TYPO3 Core Engine). See the section on $TCA in Inside TYPO3 for more details.

Usage: 12 (spec. ext. sys_action, sys_messages, sys_todos)

Parameters:
stringField list for SELECT
stringTablename, local table
stringTablename, relation table
stringTablename, foreign table
stringOptional additional WHERE clauses put in the end of the query. NOTICE: You must escape values in this argument with $this->fullQuoteStr() yourself! DO NOT PUT IN GROUP BY, ORDER BY or LIMIT! You have to prepend 'AND ' to this parameter yourself!
stringOptional GROUP BY field(s), if none, supply blank string.
stringOptional ORDER BY field(s), if none, supply blank string.
stringOptional LIMIT value ([begin,]max), if none, supply blank string.
Returns:
pointer MySQL result pointer / DBAL object
See also:
exec_SELECTquery()

Definition at line 275 of file class.t3lib_db.php.

References exec_SELECTquery().

t3lib_DB::exec_SELECT_queryArray ( queryParts)

Executes a select based on input query parts array

Usage: 9

Parameters:
arrayQuery parts array
Returns:
pointer MySQL select result pointer / DBAL object
See also:
exec_SELECTquery()

Definition at line 310 of file class.t3lib_db.php.

References exec_SELECTquery().

t3lib_DB::exec_SELECTcountRows ( field,
table,
where = '' 
)

Counts the number of rows in a table.

Parameters:
string$field,:Name of the field to use in the COUNT() expression (e.g. '*')
string$table,:Name of the table to count rows for
string$where,:(optional) WHERE statement of the query
Returns:
mixed Number of rows counter (integer) or false if something went wrong (boolean)

Definition at line 395 of file class.t3lib_db.php.

References exec_SELECTquery(), sql_fetch_row(), and sql_free_result().

t3lib_DB::exec_SELECTgetRows ( select_fields,
from_table,
where_clause,
groupBy = '',
orderBy = '',
limit = '',
uidIndexField = '' 
)

Creates and executes a SELECT SQL-statement AND traverse result set and returns array with records in.

Parameters:
stringSee exec_SELECTquery()
stringSee exec_SELECTquery()
stringSee exec_SELECTquery()
stringSee exec_SELECTquery()
stringSee exec_SELECTquery()
stringSee exec_SELECTquery()
stringIf set, the result array will carry this field names value as index. Requires that field to be selected of course!
Returns:
array Array of rows.

Definition at line 333 of file class.t3lib_db.php.

References $res, debug(), debugOutput, exec_SELECTquery(), sql_error(), sql_fetch_assoc(), and sql_free_result().

t3lib_DB::exec_SELECTgetSingleRow ( select_fields,
from_table,
where_clause,
groupBy = '',
orderBy = '',
numIndex = FALSE 
)

Creates and executes a SELECT SQL-statement AND gets a result set and returns an array with a single record in. LIMIT is automatically set to 1 and can not be overridden.

Parameters:
string$select_fields,:List of fields to select from the table.
string$from_table,:Table(s) from which to select.
string$where_clause,:Optional additional WHERE clauses put in the end of the query. NOTICE: You must escape values in this argument with $this->fullQuoteStr() yourself!
string$groupBy,:Optional GROUP BY field(s), if none, supply blank string.
string$orderBy,:Optional ORDER BY field(s), if none, supply blank string.
boolean$numIndex,:If set, the result will be fetched with sql_fetch_row, otherwise sql_fetch_assoc will be used.
Returns:
array Single row or NULL if it fails.

Definition at line 369 of file class.t3lib_db.php.

References $res, debug(), debugOutput, exec_SELECTquery(), sql_fetch_assoc(), sql_fetch_row(), and sql_free_result().

t3lib_DB::exec_SELECTquery ( select_fields,
from_table,
where_clause,
groupBy = '',
orderBy = '',
limit = '' 
)

Creates and executes a SELECT SQL-statement Using this function specifically allow us to handle the LIMIT feature independently of DB. Usage count/core: 340

Parameters:
stringList of fields to select from the table. This is what comes right after "SELECT ...". Required value.
stringTable(s) from which to select. This is what comes right after "FROM ...". Required value.
stringadditional WHERE clauses put in the end of the query. NOTICE: You must escape values in this argument with $this->fullQuoteStr() yourself! DO NOT PUT IN GROUP BY, ORDER BY or LIMIT!
stringOptional GROUP BY field(s), if none, supply blank string.
stringOptional ORDER BY field(s), if none, supply blank string.
stringOptional LIMIT value ([begin,]max), if none, supply blank string.
Returns:
pointer MySQL result pointer / DBAL object

Reimplemented in ux_t3lib_DB.

Definition at line 242 of file class.t3lib_db.php.

References $query, $res, debug(), debugOutput, explain(), SELECTquery(), and sql_num_rows().

Referenced by exec_SELECT_mm_query(), exec_SELECT_queryArray(), exec_SELECTcountRows(), exec_SELECTgetRows(), and exec_SELECTgetSingleRow().

t3lib_DB::exec_TRUNCATEquery ( table)

Truncates a table.

Parameters:
stringDatabase tablename
Returns:
mixed Result from handler

Reimplemented in ux_t3lib_DB.

Definition at line 411 of file class.t3lib_db.php.

References $res, debug(), debugOutput, and TRUNCATEquery().

t3lib_DB::exec_UPDATEquery ( table,
where,
fields_values,
no_quote_fields = FALSE 
)

Creates and executes an UPDATE SQL-statement for $table where $where-clause (typ. 'uid=...') from the array with field/value pairs $fields_values. Using this function specifically allow us to handle BLOB and CLOB fields depending on DB Usage count/core: 50

Parameters:
stringDatabase tablename
stringWHERE clause, eg. "uid=1". NOTICE: You must escape values in this argument with $this->fullQuoteStr() yourself!
arrayField values as key=>value pairs. Values will be escaped internally. Typically you would fill an array like "$updateFields" with 'fieldname'=>'value' and pass it to this function as argument.
string/arraySee fullQuoteArray()
Returns:
pointer MySQL result pointer / DBAL object

Reimplemented in ux_t3lib_DB.

Definition at line 205 of file class.t3lib_db.php.

References $res, debug(), debugOutput, and UPDATEquery().

t3lib_DB::explain ( query,
from_table,
row_count 
) [protected]

Explain select queries If $this->explainOutput is set, SELECT queries will be explained here. Only queries with more than one possible result row will be displayed. The output is either printed as raw HTML output or embedded into the TS admin panel (checkbox must be enabled!)

TODO: Feature is not DBAL-compliant

Parameters:
stringSQL query
stringTable(s) from which to select. This is what comes right after "FROM ...". Required value.
integerNumber of resulting rows
Returns:
boolean True if explain was run, false otherwise

Definition at line 1480 of file class.t3lib_db.php.

References $res.

Referenced by exec_SELECTquery().

t3lib_DB::fullQuoteArray ( arr,
table,
noQuote = FALSE 
)

Will fullquote all values in the one-dimensional array so they are ready to "implode" for an sql query.

Parameters:
arrayArray with values (either associative or non-associative array)
stringTable name for which to quote
string/arrayList/array of keys NOT to quote (eg. SQL functions) - ONLY for associative arrays
Returns:
array The input array with the values quoted
See also:
cleanIntArray()

Definition at line 783 of file class.t3lib_db.php.

Referenced by INSERTmultipleRows(), INSERTquery(), and UPDATEquery().

t3lib_DB::fullQuoteStr ( str,
table 
)

Escaping and quoting values for SQL statements. Usage count/core: 100

Parameters:
stringInput string
stringTable name for which to quote string. Just enter the table that the field-value is selected from (and any DBAL will look up which handler to use and then how to quote the string!).
Returns:
string Output string; Wrapped in single quotes and quotes in the string (" / ') and \ will be backslashed (or otherwise based on DBAL handler)
See also:
quoteStr()

Reimplemented in ux_t3lib_DB.

Definition at line 770 of file class.t3lib_db.php.

t3lib_DB::INSERTmultipleRows ( table,
array $  fields,
array $  rows,
no_quote_fields = FALSE 
)

Creates an INSERT SQL-statement for $table with multiple rows.

Parameters:
stringTable name
arrayField names
arrayTable rows. Each row should be an array with field values mapping to $fields
string/arraySee fullQuoteArray()
Returns:
string Full SQL query for INSERT (unless $rows does not contain any elements in which case it will be false)

Reimplemented in ux_t3lib_DB.

Definition at line 466 of file class.t3lib_db.php.

References $query, $row, debugOutput, and fullQuoteArray().

Referenced by exec_INSERTmultipleRows().

t3lib_DB::INSERTquery ( table,
fields_values,
no_quote_fields = FALSE 
)

Creates an INSERT SQL-statement for $table from the array with field/value pairs $fields_values. Usage count/core: 4

Parameters:
stringSee exec_INSERTquery()
arraySee exec_INSERTquery()
string/arraySee fullQuoteArray()
Returns:
string Full SQL query for INSERT (unless $fields_values does not contain any elements in which case it will be false)

Reimplemented in ux_t3lib_DB.

Definition at line 435 of file class.t3lib_db.php.

References $query, debugOutput, and fullQuoteArray().

Referenced by exec_INSERTquery().

t3lib_DB::isConnected ( )

Checks if database is connected

Returns:
boolean

Reimplemented in ux_t3lib_DB.

Definition at line 1393 of file class.t3lib_db.php.

t3lib_DB::listQuery ( field,
value,
table 
)

Returns a WHERE clause that can find a value ($value) in a list field ($field) For instance a record in the database might contain a list of numbers, "34,234,5" (with no spaces between). This query would be able to select that record based on the value "34", "234" or "5" regardless of their position in the list (left, middle or right). The value must not contain a comma (,) Is nice to look up list-relations to records or files in TYPO3 database tables.

Parameters:
stringField name
stringValue to find in list
stringTable in which we are searching (for DBAL detection of quoteStr() method)
Returns:
string WHERE clause for a query

Definition at line 651 of file class.t3lib_db.php.

References $value, and quoteStr().

t3lib_DB::prepare_SELECTquery ( select_fields,
from_table,
where_clause,
groupBy = '',
orderBy = '',
limit = '',
array $  input_parameters = array() 
)

Creates a SELECT prepared SQL statement.

Parameters:
stringSee exec_SELECTquery()
stringSee exec_SELECTquery()
stringSee exec_SELECTquery()
stringSee exec_SELECTquery()
stringSee exec_SELECTquery()
stringSee exec_SELECTquery()
array$input_parametersAn array of values with as many elements as there are bound parameters in the SQL statement being executed. All values are treated as t3lib_db_PreparedStatement::PARAM_AUTOTYPE.
Returns:
t3lib_db_PreparedStatement Prepared statement

Reimplemented in ux_t3lib_DB.

Definition at line 699 of file class.t3lib_db.php.

References $query, $value, t3lib_div\makeInstance(), and t3lib_db_PreparedStatement\PARAM_AUTOTYPE.

t3lib_DB::prepare_SELECTqueryArray ( array $  queryParts,
array $  input_parameters = array() 
)

Creates a SELECT prepared SQL statement based on input query parts array

Parameters:
arrayQuery parts array
array$input_parametersAn array of values with as many elements as there are bound parameters in the SQL statement being executed. All values are treated as t3lib_db_PreparedStatement::PARAM_AUTOTYPE.
Returns:
t3lib_db_PreparedStatement Prepared statement

Definition at line 720 of file class.t3lib_db.php.

t3lib_DB::quoteStr ( str,
table 
)

Substitution for PHP function "addslashes()" Use this function instead of the PHP addslashes() function when you build queries - this will prepare your code for DBAL. NOTICE: You must wrap the output of this function in SINGLE QUOTES to be DBAL compatible. Unless you have to apply the single quotes yourself you should rather use ->fullQuoteStr()!

Usage count/core: 20

Parameters:
stringInput string
stringTable name for which to quote string. Just enter the table that the field-value is selected from (and any DBAL will look up which handler to use and then how to quote the string!).
Returns:
string Output string; Quotes (" / ') and \ will be backslashed (or otherwise based on DBAL handler)
See also:
quoteStr()

Reimplemented in ux_t3lib_DB.

Definition at line 811 of file class.t3lib_db.php.

Referenced by listQuery().

t3lib_DB::searchQuery ( searchWords,
fields,
table 
)

Returns a WHERE clause which will make an AND search for the words in the $searchWords array in any of the fields in array $fields.

Parameters:
arrayArray of search words
arrayArray of fields
stringTable in which we are searching (for DBAL detection of quoteStr() method)
Returns:
string WHERE clause for search

Definition at line 669 of file class.t3lib_db.php.

t3lib_DB::SELECTquery ( select_fields,
from_table,
where_clause,
groupBy = '',
orderBy = '',
limit = '' 
)

Creates a SELECT SQL-statement Usage count/core: 11

Parameters:
stringSee exec_SELECTquery()
stringSee exec_SELECTquery()
stringSee exec_SELECTquery()
stringSee exec_SELECTquery()
stringSee exec_SELECTquery()
stringSee exec_SELECTquery()
Returns:
string Full SQL query for SELECT

Reimplemented in ux_t3lib_DB.

Definition at line 572 of file class.t3lib_db.php.

References $query, and debugOutput.

Referenced by exec_SELECTquery().

t3lib_DB::SELECTsubquery ( select_fields,
from_table,
where_clause 
)

Creates a SELECT SQL-statement to be used as subquery within another query. BEWARE: This method should not be overriden within DBAL to prevent quoting from happening.

Parameters:
string$select_fields,:List of fields to select from the table.
string$from_table,:Table from which to select.
string$where_clause,:Conditional WHERE statement
Returns:
string Full SQL query for SELECT

Definition at line 604 of file class.t3lib_db.php.

References $query, and debugOutput.

t3lib_DB::setSqlMode ( ) [protected]

Fixes the SQL mode by unsetting NO_BACKSLASH_ESCAPES if found.

Returns:
void

Definition at line 1173 of file class.t3lib_db.php.

References $query, and t3lib_div\trimExplode().

t3lib_DB::splitGroupOrderLimit ( str)

Takes the last part of a query, eg. "... uid=123 GROUP BY title ORDER BY title LIMIT 5,2" and splits each part into a table (WHERE, GROUPBY, ORDERBY, LIMIT) Work-around function for use where you know some userdefined end to an SQL clause is supplied and you need to separate these factors. Usage count/core: 13

Parameters:
stringInput string
Returns:
array

Definition at line 892 of file class.t3lib_db.php.

t3lib_DB::sql_affected_rows ( )

Returns the number of rows affected by the last INSERT, UPDATE or DELETE query mysql_affected_rows() wrapper function Usage count/core: 1

Returns:
integer Number of rows affected by last query

Reimplemented in ux_t3lib_DB.

Definition at line 1061 of file class.t3lib_db.php.

t3lib_DB::sql_data_seek ( res,
seek 
)

Move internal result pointer mysql_data_seek() wrapper function Usage count/core: 3

Parameters:
pointerMySQL result pointer (of SELECT query) / DBAL object
integerSeek result number.
Returns:
boolean Returns TRUE on success or FALSE on failure.

Definition at line 1074 of file class.t3lib_db.php.

References $res.

t3lib_DB::sql_errno ( )

Returns the error number on the last sql() execution mysql_errno() wrapper function

Returns:
int MySQL error number.

Reimplemented in ux_t3lib_DB.

Definition at line 974 of file class.t3lib_db.php.

t3lib_DB::sql_error ( )

Returns the error status on the last sql() execution mysql_error() wrapper function Usage count/core: 32

Returns:
string MySQL error string.

Reimplemented in ux_t3lib_DB.

Definition at line 964 of file class.t3lib_db.php.

Referenced by exec_SELECTgetRows().

t3lib_DB::sql_fetch_assoc ( res)

Returns an associative array that corresponds to the fetched row, or FALSE if there are no more rows. mysql_fetch_assoc() wrapper function Usage count/core: 307

Parameters:
pointerMySQL result pointer (of SELECT query) / DBAL object
Returns:
array Associative array of result row.

Definition at line 1002 of file class.t3lib_db.php.

References $res.

Referenced by exec_SELECTgetRows(), and exec_SELECTgetSingleRow().

t3lib_DB::sql_fetch_row ( res)

Returns an array that corresponds to the fetched row, or FALSE if there are no more rows. The array contains the values in numerical indices. mysql_fetch_row() wrapper function Usage count/core: 56

Parameters:
pointerMySQL result pointer (of SELECT query) / DBAL object
Returns:
array Array with result rows.

Definition at line 1019 of file class.t3lib_db.php.

References $res.

Referenced by exec_SELECTcountRows(), and exec_SELECTgetSingleRow().

t3lib_DB::sql_field_type ( res,
pointer 
)

Get the type of the specified field in a result mysql_field_type() wrapper function Usage count/core: 2

Parameters:
pointerMySQL result pointer (of SELECT query) / DBAL object
integerField index.
Returns:
string Returns the name of the specified field index

Definition at line 1091 of file class.t3lib_db.php.

References $res.

t3lib_DB::sql_free_result ( res)

Free result memory mysql_free_result() wrapper function Usage count/core: 3

Parameters:
pointerMySQL result pointer to free / DBAL object
Returns:
boolean Returns TRUE on success or FALSE on failure.

Definition at line 1035 of file class.t3lib_db.php.

References $res.

Referenced by exec_SELECTcountRows(), exec_SELECTgetRows(), and exec_SELECTgetSingleRow().

t3lib_DB::sql_insert_id ( )

Get the ID generated from the previous INSERT operation mysql_insert_id() wrapper function Usage count/core: 13

Returns:
integer The uid of the last inserted record.

Reimplemented in ux_t3lib_DB.

Definition at line 1050 of file class.t3lib_db.php.

t3lib_DB::sql_num_rows ( res)

Returns the number of selected rows. mysql_num_rows() wrapper function Usage count/core: 85

Parameters:
pointerMySQL result pointer (of SELECT query) / DBAL object
Returns:
integer Number of resulting rows

Definition at line 986 of file class.t3lib_db.php.

References $res.

Referenced by exec_SELECTquery().

t3lib_DB::sql_pconnect ( TYPO3_db_host,
TYPO3_db_username,
TYPO3_db_password 
)

Open a (persistent) connection to a MySQL server mysql_pconnect() wrapper function Usage count/core: 12

Parameters:
stringDatabase host IP/domain
stringUsername to connect with.
stringPassword to connect with.
Returns:
pointer Returns a positive MySQL persistent link identifier on success, or FALSE on error.

Reimplemented in ux_t3lib_DB.

Definition at line 1109 of file class.t3lib_db.php.

References $GLOBALS, and t3lib_div\trimExplode().

t3lib_DB::sql_query ( query)

Executes query mysql_query() wrapper function Beware: Use of this method should be avoided as it is experimentally supported by DBAL. You should consider using exec_SELECTquery() and similar methods instead. Usage count/core: 1

Parameters:
stringQuery to execute
Returns:
pointer Result pointer / DBAL object

Reimplemented in ux_t3lib_DB.

Definition at line 949 of file class.t3lib_db.php.

References $query, $res, debug(), and debugOutput.

t3lib_DB::sql_select_db ( TYPO3_db)

Select a MySQL database mysql_select_db() wrapper function Usage count/core: 8

Parameters:
stringDatabase to connect to.
Returns:
boolean Returns TRUE on success or FALSE on failure.

Reimplemented in ux_t3lib_DB.

Definition at line 1202 of file class.t3lib_db.php.

t3lib_DB::stripGroupBy ( str)

Removes the prefix "GROUP BY" from the input string. This function is used when you call the SELECTquery() function and want to pass the GROUP BY parameter by can't guarantee that "GROUP BY" is not prefixed. Generally; This function provides a work-around to the situation where you cannot pass only the fields by which to order the result. Usage count/core: 1

Parameters:
stringeg. "GROUP BY title, uid"
Returns:
string eg. "title, uid"
See also:
exec_SELECTquery(), stripOrderBy()

Definition at line 880 of file class.t3lib_db.php.

t3lib_DB::stripOrderBy ( str)

Removes the prefix "ORDER BY" from the input string. This function is used when you call the exec_SELECTquery() function and want to pass the ORDER BY parameter by can't guarantee that "ORDER BY" is not prefixed. Generally; This function provides a work-around to the situation where you cannot pass only the fields by which to order the result. Usage count/core: 11

Parameters:
stringeg. "ORDER BY title, uid"
Returns:
string eg. "title, uid"
See also:
exec_SELECTquery(), stripGroupBy()

Definition at line 866 of file class.t3lib_db.php.

t3lib_DB::TRUNCATEquery ( table)

Creates a TRUNCATE TABLE SQL-statement

Parameters:
stringSee exec_TRUNCATEquery()
Returns:
string Full SQL query for TRUNCATE TABLE

Reimplemented in ux_t3lib_DB.

Definition at line 624 of file class.t3lib_db.php.

References $query, and debugOutput.

Referenced by exec_TRUNCATEquery().

t3lib_DB::UPDATEquery ( table,
where,
fields_values,
no_quote_fields = FALSE 
)

Creates an UPDATE SQL-statement for $table where $where-clause (typ. 'uid=...') from the array with field/value pairs $fields_values. Usage count/core: 6

Parameters:
stringSee exec_UPDATEquery()
stringSee exec_UPDATEquery()
arraySee exec_UPDATEquery()
arraySee fullQuoteArray()
Returns:
string Full SQL query for UPDATE

Reimplemented in ux_t3lib_DB.

Definition at line 502 of file class.t3lib_db.php.

References $query, debugOutput, and fullQuoteArray().

Referenced by exec_UPDATEquery().


Member Data Documentation

t3lib_DB::$debug_lastBuiltQuery = ''

Definition at line 135 of file class.t3lib_db.php.

t3lib_DB::$debugOutput = FALSE

Definition at line 134 of file class.t3lib_db.php.

t3lib_DB::$default_charset = 'utf8'

Definition at line 143 of file class.t3lib_db.php.

t3lib_DB::$explainOutput = 0

Definition at line 137 of file class.t3lib_db.php.

t3lib_DB::$link = FALSE

Definition at line 140 of file class.t3lib_db.php.

Referenced by ux_t3lib_DB\handler_init().

t3lib_DB::$store_lastBuiltQuery = FALSE

Definition at line 136 of file class.t3lib_db.php.


The documentation for this class was generated from the following file: