Solutions Open Source

Référence de la classe t3lib_DB

Graphe d'héritage de t3lib_DB:

Inheritance graph
[légende]

Liste de tous les membres

Fonctions membres publiques

 exec_INSERTquery ($table, $fields_values, $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='')
 INSERTquery ($table, $fields_values, $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='')
 listQuery ($field, $value, $table)
 searchQuery ($searchWords, $fields, $table)
 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 ($db, $query)
 sql_query ($query)
 sql_error ()
 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_query ($query)
 connectDB ()
 debug ($func, $query='')
 debug_check_recordset ($res)

Attributs publics

 $debugOutput = FALSE
 $debug_lastBuiltQuery = ''
 $store_lastBuiltQuery = FALSE
 $link = FALSE


Documentation des fonctions membres

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

Paramètres:
string Table name
array Field 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/array See fullQuoteArray()
Renvoie:
pointer MySQL result pointer / DBAL object

Réimplémentée dans ux_t3lib_DB.

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

Paramètres:
string Database tablename
string WHERE clause, eg. "uid=1". NOTICE: You must escape values in this argument with $this->fullQuoteStr() yourself!
array Field 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/array See fullQuoteArray()
Renvoie:
pointer MySQL result pointer / DBAL object

Réimplémentée dans ux_t3lib_DB.

t3lib_DB::exec_DELETEquery ( table,
where 
)

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

Paramètres:
string Database tablename
string WHERE clause, eg. "uid=1". NOTICE: You must escape values in this argument with $this->fullQuoteStr() yourself!
Renvoie:
pointer MySQL result pointer / DBAL object

Réimplémentée dans ux_t3lib_DB.

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

Paramètres:
string List of fields to select from the table. This is what comes right after "SELECT ...". Required value.
string Table(s) from which to select. This is what comes right after "FROM ...". Required value.
string Optional 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!
string Optional GROUP BY field(s), if none, supply blank string.
string Optional ORDER BY field(s), if none, supply blank string.
string Optional LIMIT value ([begin,]max), if none, supply blank string.
Renvoie:
pointer MySQL result pointer / DBAL object

Réimplémentée dans ux_t3lib_DB.

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)

Paramètres:
string Field list for SELECT
string Tablename, local table
string Tablename, relation table
string Tablename, foreign table
string Optional 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!
string Optional GROUP BY field(s), if none, supply blank string.
string Optional ORDER BY field(s), if none, supply blank string.
string Optional LIMIT value ([begin,]max), if none, supply blank string.
Renvoie:
pointer MySQL result pointer / DBAL object
Voir également:
exec_SELECTquery()

t3lib_DB::exec_SELECT_queryArray ( queryParts  ) 

Executes a select based on input query parts array

Usage: 9

Paramètres:
array Query parts array
Renvoie:
pointer MySQL select result pointer / DBAL object
Voir également:
exec_SELECTquery()

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.

Paramètres:
string See exec_SELECTquery()
string See exec_SELECTquery()
string See exec_SELECTquery()
string See exec_SELECTquery()
string See exec_SELECTquery()
string See exec_SELECTquery()
string If set, the result array will carry this field names value as index. Requires that field to be selected of course!
Renvoie:
array Array of rows.

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

Paramètres:
string See exec_INSERTquery()
array See exec_INSERTquery()
string/array See fullQuoteArray()
Renvoie:
string Full SQL query for INSERT (unless $fields_values does not contain any elements in which case it will be false)
Obsolète:
use exec_INSERTquery() instead if possible!

Réimplémentée dans ux_t3lib_DB.

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

Paramètres:
string See exec_UPDATEquery()
string See exec_UPDATEquery()
array See exec_UPDATEquery()
array See fullQuoteArray()
Renvoie:
string Full SQL query for UPDATE (unless $fields_values does not contain any elements in which case it will be false)
Obsolète:
use exec_UPDATEquery() instead if possible!

Réimplémentée dans ux_t3lib_DB.

t3lib_DB::DELETEquery ( table,
where 
)

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

Paramètres:
string See exec_DELETEquery()
string See exec_DELETEquery()
Renvoie:
string Full SQL query for DELETE
Obsolète:
use exec_DELETEquery() instead if possible!

Réimplémentée dans ux_t3lib_DB.

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

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

Paramètres:
string See exec_SELECTquery()
string See exec_SELECTquery()
string See exec_SELECTquery()
string See exec_SELECTquery()
string See exec_SELECTquery()
string See exec_SELECTquery()
Renvoie:
string Full SQL query for SELECT
Obsolète:
use exec_SELECTquery() instead if possible!

Réimplémentée dans ux_t3lib_DB.

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 positioni in the list (left, middle or right). Is nice to look up list-relations to records or files in TYPO3 database tables.

Paramètres:
string Field name
string Value to find in list
string Table in which we are searching (for DBAL detection of quoteStr() method)
Renvoie:
string WHERE clause for a query

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.

Paramètres:
array Array of search words
array Array of fields
string Table in which we are searching (for DBAL detection of quoteStr() method)
Renvoie:
string WHERE clause for search

t3lib_DB::fullQuoteStr ( str,
table 
)

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

Paramètres:
string Input string
string Table 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!).
Renvoie:
string Output string; Wrapped in single quotes and quotes in the string (" / ') and \ will be backslashed (or otherwise based on DBAL handler)
Voir également:
quoteStr()

Réimplémentée dans ux_t3lib_DB.

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.

Paramètres:
array Array with values (either associative or non-associative array)
string Table name for which to quote
string/array List/array of keys NOT to quote (eg. SQL functions) - ONLY for associative arrays
Renvoie:
array The input array with the values quoted
Voir également:
cleanIntArray()

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

Paramètres:
string Input string
string Table 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!).
Renvoie:
string Output string; Quotes (" / ') and \ will be backslashed (or otherwise based on DBAL handler)
Voir également:
quoteStr()

Réimplémentée dans ux_t3lib_DB.

t3lib_DB::escapeStrForLike ( str,
table 
)

Escaping values for SQL LIKE statements.

Paramètres:
string Input string
string Table 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!).
Renvoie:
string Output string; % and _ will be escaped with \ (or otherwise based on DBAL handler)
Voir également:
quoteStr()

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

Paramètres:
array Array with values
Renvoie:
array The input array with all values passed through intval()
Voir également:
cleanIntList()

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

Paramètres:
string List of comma-separated values which should be integers
Renvoie:
string The input list but with every value passed through intval()
Voir également:
cleanIntArray()

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

Paramètres:
string eg. "ORDER BY title, uid"
Renvoie:
string eg. "title, uid"
Voir également:
exec_SELECTquery(), stripGroupBy()

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

Paramètres:
string eg. "GROUP BY title, uid"
Renvoie:
string eg. "title, uid"
Voir également:
exec_SELECTquery(), stripOrderBy()

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

Paramètres:
string Input string
Renvoie:
array

t3lib_DB::sql ( db,
query 
)

Executes query mysql() wrapper function DEPRECATED - use exec_* functions from this class instead! Usage count/core: 9

Paramètres:
string Database name
string Query to execute
Renvoie:
pointer Result pointer / DBAL object

Réimplémentée dans ux_t3lib_DB.

t3lib_DB::sql_query ( query  ) 

Executes query mysql_query() wrapper function Usage count/core: 1

Paramètres:
string Query to execute
Renvoie:
pointer Result pointer / DBAL object

Réimplémentée dans ux_t3lib_DB.

t3lib_DB::sql_error (  ) 

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

Renvoie:
string MySQL error string.

Réimplémentée dans ux_t3lib_DB.

t3lib_DB::sql_num_rows ( res  ) 

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

Paramètres:
pointer MySQL result pointer (of SELECT query) / DBAL object
Renvoie:
integer Number of resulting rows.

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

Paramètres:
pointer MySQL result pointer (of SELECT query) / DBAL object
Renvoie:
array Associative array of result row.

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

Paramètres:
pointer MySQL result pointer (of SELECT query) / DBAL object
Renvoie:
array Array with result rows.

t3lib_DB::sql_free_result ( res  ) 

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

Paramètres:
pointer MySQL result pointer to free / DBAL object
Renvoie:
boolean Returns TRUE on success or FALSE on failure.

t3lib_DB::sql_insert_id (  ) 

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

Renvoie:
integer The uid of the last inserted record.

Réimplémentée dans ux_t3lib_DB.

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

Renvoie:
integer Number of rows affected by last query

Réimplémentée dans ux_t3lib_DB.

t3lib_DB::sql_data_seek ( res,
seek 
)

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

Paramètres:
pointer MySQL result pointer (of SELECT query) / DBAL object
integer Seek result number.
Renvoie:
boolean Returns TRUE on success or FALSE on failure.

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

Paramètres:
pointer MySQL result pointer (of SELECT query) / DBAL object
integer Field index.
Renvoie:
string Returns the name of the specified field index

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

Paramètres:
string Database host IP/domain
string Username to connect with.
string Password to connect with.
Renvoie:
pointer Returns a positive MySQL persistent link identifier on success, or FALSE on error.

Réimplémentée dans ux_t3lib_DB.

t3lib_DB::sql_select_db ( TYPO3_db  ) 

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

Paramètres:
string Database to connect to.
Renvoie:
boolean Returns TRUE on success or FALSE on failure.

Réimplémentée dans ux_t3lib_DB.

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

Renvoie:
array Each entry represents a database name

Réimplémentée dans ux_t3lib_DB.

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

Renvoie:
array Tables in an array (tablename is in both key and value)

Réimplémentée dans ux_t3lib_DB.

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.

Paramètres:
string Table name
Renvoie:
array Field information in an associative array with fieldname => field row

Réimplémentée dans ux_t3lib_DB.

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

Paramètres:
string Table name
Renvoie:
array Key information in a numeric array

Réimplémentée dans ux_t3lib_DB.

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

Paramètres:
string Query to execute
Renvoie:
pointer Result pointer

Réimplémentée dans ux_t3lib_DB.

t3lib_DB::connectDB (  ) 

Connects to database for TYPO3 sites:

Renvoie:
void

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

Debug function: Outputs error if any

Paramètres:
string Function calling debug()
string Last query if not last built query
Renvoie:
void

t3lib_DB::debug_check_recordset ( res  ) 

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

Paramètres:
resource $res Recordset
Renvoie:
boolean false if recordset is not valid


Documentation des données membres

t3lib_DB::$debugOutput = FALSE

t3lib_DB::$debug_lastBuiltQuery = ''

t3lib_DB::$store_lastBuiltQuery = FALSE

t3lib_DB::$link = FALSE


La documentation de cette classe a été générée à partir du fichier suivant :
Généré le Fri Aug 31 11:42:07 2007 pour OBLADY - Typo3 API v4.1.2 par  doxygen 1.5.3