| [ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
[Code source] [Imprimer] [Statistiques]
Database abstraction library
| Author: | Ralf Becker <RalfBecker@outdoor-training.de> |
| License: | LGPL |
| Poids: | 1692 lignes (54 kb) |
| Inclus ou requis: | 1 fois |
| Référencé: | 0 fois |
| Nécessite: | 1 fichier phpgwapi/inc/adodb/adodb.inc.php |
egw_db:: (51 méthodes):
db()
link_id()
query_id()
connect()
set_capabilities()
disconnect()
db_addslashes()
to_timestamp()
from_timestamp()
from_bool()
free()
query()
limit_query()
next_record()
seek()
transaction_begin()
transaction_commit()
transaction_abort()
get_last_insert_id()
lock()
unlock()
affected_rows()
num_rows()
num_fields()
nf()
np()
f()
p()
row()
halt()
haltmsg()
metadata()
table_names()
index_names()
pkey_columns()
create_database()
concat()
from_unixtime()
date_format()
name_quote()
quote()
column_data_implode()
set_column_definitions()
set_app()
get_table_definitions()
insert()
update()
delete()
expression()
select()
union()
| db($query = '') X-Ref |
param: string $query query to be executed (optional) |
| link_id() X-Ref |
return: int current connection id |
| query_id() X-Ref |
return: int id of current query |
| connect($Database = NULL, $Host = NULL, $Port = NULL, $User = NULL, $Password = NULL,$Type = NULL) X-Ref |
| Open a connection to a database param: string $Database name of database to use (optional) param: string $Host database host to connect to (optional) param: string $Port database port to connect to (optional) param: string $User name of database user (optional) param: string $Password password for database user (optional) |
| set_capabilities($adodb_driver,$db_version) X-Ref |
| changes defaults set in class-var $capabilities depending on db-type and -version param: string $ado_driver mysql, postgres, mssql, sapdb, oci8 param: string $db_version version-number of connected db-server, as reported by ServerInfo |
| disconnect() X-Ref |
| Close a connection to a database |
| db_addslashes($str) X-Ref |
| Escape strings before sending them to the database param: string $str the string to be escaped return: string escaped sting |
| to_timestamp($epoch) X-Ref |
| Convert a unix timestamp to a rdms specific timestamp param: int unix timestamp return: string rdms specific timestamp |
| from_timestamp($timestamp) X-Ref |
| Convert a rdms specific timestamp to a unix timestamp param: string rdms specific timestamp return: int unix timestamp |
| from_bool($val) X-Ref |
| convert a rdbms specific boolean value param: string $val boolean value in db-specfic notation return: boolean |
| free() X-Ref |
| Discard the current query result |
| query($Query_String, $line = '', $file = '', $offset=0, $num_rows=-1,$inputarr=false) X-Ref |
| Execute a query param: string $Query_String the query to be executed param: int $line the line method was called from - use __LINE__ param: string $file the file method was called from - use __FILE__ param: int $offset row to start from, default 0 param: int $num_rows number of rows to return (optional), default -1 = all, 0 will use $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'] param: array/boolean $inputarr array for binding variables to parameters or false (default) return: ADORecordSet or false, if the query fails |
| limit_query($Query_String, $offset, $line = '', $file = '', $num_rows = '',$inputarr=false) X-Ref |
| Execute a query with limited result set param: string $Query_String the query to be executed param: int $offset row to start from, default 0 param: int $line the line method was called from - use __LINE__ param: string $file the file method was called from - use __FILE__ param: int $num_rows number of rows to return (optional), default -1 = all, 0 will use $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'] param: array/boolean $inputarr array for binding variables to parameters or false (default) return: ADORecordSet or false, if the query fails |
| next_record($fetch_mode=ADODB_FETCH_BOTH) X-Ref |
| Move to the next row in the results set Specifying a fetch_mode only works for newly fetched rows, the first row always gets fetched by query!!! param: int $fetch_mode ADODB_FETCH_BOTH = numerical+assoc keys (eGW default), ADODB_FETCH_ASSOC or ADODB_FETCH_NUM return: bool was another row found? |
| seek($pos = 0) X-Ref |
| Move to position in result set param: int $pos required row (optional), default first row return: boolean true if sucessful or false if not found |
| transaction_begin() X-Ref |
| Begin Transaction return: int/boolean current transaction-id, of false if no connection |
| transaction_commit() X-Ref |
| Complete the transaction return: bool True if sucessful, False if fails |
| transaction_abort() X-Ref |
| Rollback the current transaction return: bool True if sucessful, False if fails |
| get_last_insert_id($table, $field) X-Ref |
| Find the primary key of the last insertion on the current db connection param: string $table name of table the insert was performed on param: string $field the autoincrement primary key of the table return: int the id, -1 if fails |
| lock($table, $mode='write') X-Ref |
| Pas de description |
| unlock() X-Ref |
| Unlock a table return: bool True if sucessful, False if fails |
| affected_rows() X-Ref |
| Get the number of rows affected by last update or delete return: int number of rows |
| num_rows() X-Ref |
| Number of rows in current result set return: int number of rows |
| num_fields() X-Ref |
| Number of fields in current row return: int number of fields |
| nf() X-Ref |
| np() X-Ref |
| f($Name, $strip_slashes = False) X-Ref |
| Return the value of a column param: string/integer $Name name of field or positional index starting from 0 param: bool $strip_slashes string escape chars from field(optional), default false return: string the field value |
| p($Name, $strip_slashes = True) X-Ref |
| Print the value of a field param: string $Name name of field to print param: bool $strip_slashes string escape chars from field(optional), default false |
| row($do_next_record=False,$strip='') X-Ref |
| Returns a query-result-row as an associative array (no numerical keys !!!) param: bool $do_next_record should next_record() be called or not (default not) param: string $strip='' string to strip of the column-name, default '' return: array/bool the associative array or False if no (more) result-row is availible |
| halt($msg, $line = '', $file = '') X-Ref |
| Error handler param: string $msg error message param: int $line line of calling method/function (optional) param: string $file file of calling method/function (optional) |
| haltmsg($msg) X-Ref |
| Pas de description |
| metadata($table='',$full=false) X-Ref |
| Get description of a table Beside the column-name all other data depends on the db-type !!! param: string $table name of table to describe param: bool $full optional, default False summary information, True full information return: array table meta data |
| table_names() X-Ref |
| Get a list of table names in the current database return: array list of the tables |
| index_names() X-Ref |
| Return a list of indexes in current database return: array list of indexes |
| pkey_columns($tablename) X-Ref |
| Returns an array containing column names that are the primary keys of $tablename. return: array of columns |
| create_database($adminname = '', $adminpasswd = '', $charset='') X-Ref |
| Create a new database param: string $adminname name of database administrator user (optional) param: string $adminpasswd password for the database administrator user (optional) param: string $charset default charset for the database |
| concat($str1) X-Ref |
| concat a variable number of strings together, to be used in a query Example: $db->concat($db->quote('Hallo '),'username') would return for mysql "concat('Hallo ',username)" or "'Hallo ' || username" for postgres param: string $str1 already quoted stringliteral or column-name, variable number of arguments return: string to be used in a query |
| from_unixtime($expr) X-Ref |
| Convert a unix timestamp stored as integer in the db into a db timestamp, like MySQL: FROM_UNIXTIME(ts) param: string $expr name of an integer column or integer expression return: string SQL expression of type timestamp |
| date_format($expr,$format) X-Ref |
| format a timestamp as string, like MySQL: DATE_FORMAT(ts) Please note: only a subset of the MySQL formats are implemented param: string $expr name of a timestamp column or timestamp expression param: string $format format specifier like '%Y-%m-%d %H:%i:%s' or '%V%X' ('%v%x') weeknumber & year with Sunday (Monday) as first day return: string SQL expression of type timestamp |
| name_quote($name = NULL) X-Ref |
| Correctly Quote Identifiers like table- or colmnnames for use in SQL-statements This is mostly copy & paste from adodb's datadict class param: $name string return: string quoted string |
| quote($value,$type=False,$not_null=true) X-Ref |
| Escape values before sending them to the database - prevents SQL injunction and SQL errors ;-) Please note that the quote function already returns necessary quotes: quote('Hello') === "'Hello'". Int and Auto types are casted to int: quote('1','int') === 1, quote('','int') === 0, quote('Hello','int') === 0 param: mixed $value the value to be escaped param: string/boolean $type string the type of the db-column, default False === varchar param: boolean $not_null is column NOT NULL, default true, else php null values are written as SQL NULL return: string escaped sting |
| column_data_implode($glue,$array,$use_key=True,$only=False,$column_definitions=False) X-Ref |
| Implodes an array of column-value pairs for the use in sql-querys. All data is run through quote (does either addslashes() or (int)) - prevents SQL injunction and SQL errors ;-). author: RalfBecker<at>outdoor-training.de param: string $glue in most cases this will be either ',' or ' AND ', depending you your query param: array $array column-name / value pairs, if the value is an array all its array-values will be quoted param: boolean/string $use_key If $use_key===True a "$key=" prefix each value (default), typically set to False param: array/boolean $only if set to an array only colums which are set (as data !!!) are written param: array/boolean $column_definitions this can be set to the column-definitions-array return: string SQL |
| set_column_definitions($column_definitions=False) X-Ref |
| Sets the default column-definitions for use with column_data_implode() author: RalfBecker<at>outdoor-training.de param: array/boolean $column_definitions this can be set to the column-definitions-array |
| set_app($app) X-Ref |
| Sets the application in which the db-class looks for table-defintions Used by table_definitions, insert, update, select, expression and delete. If the app is not set via set_app, it need to be set for these functions on every call param: string $app the app-name |
| get_table_definitions($app=False,$table=False) X-Ref |
| reads the table-definitions from the app's setup/tables_current.inc.php file The already read table-definitions are shared between all db-instances via $GLOBALS['egw_info']['apps'][$app]['table_defs'] author: RalfBecker<at>outdoor-training.de param: bool/string $app name of the app or default False to use the app set by db::set_app or the current app, param: bool/string $table if set return only defintions of that table, else return all defintions return: mixed array with table-defintions or False if file not found |
| insert($table,$data,$where,$line,$file,$app=False,$use_prepared_statement=false,$table_def=False) X-Ref |
| Insert a row of data into a table or updates it if $where is given, all data is quoted according to it's type author: RalfBecker<at>outdoor-training.de param: string $table name of the table param: array $data with column-name / value pairs param: mixed $where string with where clause or array with column-name / values pairs to check if a row with that keys already exists, or false for an unconditional insert param: int $line line-number to pass to query param: string $file file-name to pass to query param: string/boolean $app string with name of app or False to use the current-app param: bool $use_prepared_statement use a prepared statement param: array/bool $table_def use this table definition. If False, the table definition will be read from tables_baseline return: ADORecordSet or false, if the query fails |
| update($table,$data,$where,$line,$file,$app=False,$use_prepared_statement=false,$table_def=False) X-Ref |
| Updates the data of one or more rows in a table, all data is quoted according to it's type author: RalfBecker<at>outdoor-training.de param: string $table name of the table param: array $data with column-name / value pairs param: array $where column-name / values pairs and'ed together for the where clause param: int $line line-number to pass to query param: string $file file-name to pass to query param: string/boolean $app string with name of app or False to use the current-app param: bool $use_prepared_statement use a prepared statement param: array/bool $table_def use this table definition. If False, the table definition will be read from tables_baseline return: ADORecordSet or false, if the query fails |
| delete($table,$where,$line,$file,$app=False,$table_def=False) X-Ref |
| Deletes one or more rows in table, all data is quoted according to it's type author: RalfBecker<at>outdoor-training.de param: string $table name of the table param: array $where column-name / values pairs and'ed together for the where clause param: int $line line-number to pass to query param: string $file file-name to pass to query param: string/boolean $app string with name of app or False to use the current-app param: array/bool $table_def use this table definition. If False, the table definition will be read from tables_baseline return: ADORecordSet or false, if the query fails |
| expression($table_def,$args) X-Ref |
| Formats and quotes a sql expression to be used eg. as where-clause The function has a variable number of arguments, from which the expession gets constructed eg. db::expression('my_table','(',array('name'=>"test'ed",'lang'=>'en'),') OR ',array('owner'=>array('',4,10))) gives "(name='test\'ed' AND lang='en') OR 'owner' IN (0,4,5,6,10)" if name,lang are strings and owner is an integer param: string/array $table_def table-name or definition array param: mixed $args variable number of arguments of the following types: return: string the expression generated from the arguments |
| select($table,$cols,$where,$line,$file,$offset=False,$append='',$app=False,$num_rows=0,$join='',$table_def=False) X-Ref |
| Selects one or more rows in table depending on where, all data is quoted according to it's type author: RalfBecker<at>outdoor-training.de param: string $table name of the table param: array/string $cols string or array of column-names / select-expressions param: array/string $where string or array with column-name / values pairs AND'ed together for the where clause param: int $line line-number to pass to query param: string $file file-name to pass to query param: int/bool $offset offset for a limited query or False (default) param: string $append string to append to the end of the query, eg. ORDER BY ... param: string/boolean $app string with name of app or False to use the current-app param: int $num_rows number of rows to return if offset set, default 0 = use default in user prefs param: string $join=null sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or param: array/bool $table_def use this table definition. If False, the table definition will be read from tables_baseline return: ADORecordSet or false, if the query fails |
| union($selects,$line,$file,$order_by='',$offset=false,$num_rows=0) X-Ref |
| Does a union over multiple selects author: RalfBecker<at>outdoor-training.de param: array $selects array of selects, each select is an array with the possible keys/parameters: table, cols, where, append, app, join, table_def param: int $line line-number to pass to query param: string $file file-name to pass to query param: string $order_by ORDER BY statement for the union param: int/bool $offset offset for a limited query or False (default) param: int $num_rows number of rows to return if offset set, default 0 = use default in user prefs return: ADORecordSet or false, if the query fails |
| Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |