Changes between Version 2 and Version 3 of commonMethods
- Timestamp:
- 04/16/08 19:01:13 (2 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
commonMethods
v2 v3 8 8 === db::function setDefaultConnectionStr($connectionStr) === 9 9 set the default connection string to be used when calling db::getInsance() with no arguments. 10 @param string $connectionStr the connection string is a semi colon separated list10 - @param string $connectionStr the connection string is a semi colon separated list 11 11 of connection parameter in the order they appear in the constructor 12 12 preceeded by !classname:// … … 24 24 ---- 25 25 === db::getInstance($connectionStr=null,$setDefault=false) === 26 static method that return a single instance of the database corresponding to the given connection String. 27 This method mustbe copyed in the exended class as php is not able to get the name of the calling class (waiting php >= 5.3 for late static binding to get rid of this).28 @param string $connectionStr the connection string is a semi colon separated list26 static method that return a single instance of the database corresponding to the given connection String.[[BR]] 27 This method '''must''' be copyed in the exended class as php is not able to get the name of the calling class (waiting php >= 5.3 for late static binding to get rid of this). 28 - @param string $connectionStr the connection string is a semi colon separated list 29 29 of connection parameter in the order they appear in the constructor 30 30 preceeded by !classname:// … … 33 33 and a sqlitedb one will look like: 34 34 "!sqlitedb://dbfile" 35 @param bool $setDefault if true then this database connection will be the default one35 - @param bool $setDefault if true then this database connection will be the default one 36 36 returned when no arguments are given. 37 37 For conveniance the first call to this method 38 38 will set the corresponding instance the default one 39 39 if none has been set before 40 @return db instance40 - @return db instance 41 41 example 42 42 {{{ … … 47 47 ---- 48 48 === default __construct() === 49 '''''This way of creating an instance is not encourage anymore! '''''50 @deprecated use @see getInstance instead49 '''''This way of creating an instance is not encourage anymore! ''''' 50 - @deprecated use @see getInstance instead 51 51 constructor stay public even if we have getInstance for 2 reason 52 52 1. backward compatibility with existing scripts … … 59 59 == Selection methods == 60 60 === select_rows($tables,$fields = '*', $conds = null,$result_type = 'ASSOC') === 61 send a select query to $table on requested $fields (all by default) and conforming to clause defined with $conditions 61 send a select query to $table on requested $fields (all by default) and conforming to clause defined with $conditions[[BR]] 62 62 see process_conds for more info on $conditions parameter 63 @param string|array $Table64 @param string|array $fields65 @param string|array $conditions66 @param string $res_type 'ASSOC', 'NUM' et 'BOTH'67 @Return array | false63 - @param string|array $Table 64 - @param string|array $fields 65 - @param string|array $conditions 66 - @param string $res_type 'ASSOC', 'NUM' et 'BOTH' 67 - @Return array | false 68 68 {{{ 69 69 #!php … … 77 77 equal to $res = select_rows followed by $res = $res[0]; 78 78 So most of the time you will use it with a condition clause ending by 'LIMIT 0,1' 79 @see select_rows for details80 @return array of fields79 - @see select_rows for details 80 - @return array of fields 81 81 {{{ 82 82 #!php … … 87 87 88 88 === select_associative($tables,$fields='*',$conds=null,$index_field='id',$value_fields=null,$keep_index=FALSE) === 89 just a quick way to do a select_rows followed by a associative_array_from_q2a_res 89 just a quick way to do a select_rows followed by a associative_array_from_q2a_res[[BR]] 90 90 see both thoose method for more information about parameters or return values 91 91 ''(in fact you will certainly rarely use associative_array_from_q2a_res but use select_associative most of the time)'' … … 117 117 === select_value($table,$field,$conds=null) === 118 118 select a single value in database 119 @param string $table120 @param string $field the field name where to pick-up value121 @param mixed conds122 @return mixed or FALSE119 - @param string $table 120 - @param string $field the field name where to pick-up value 121 - @param mixed conds 122 - @return mixed or FALSE 123 123 {{{ 124 124 #!php … … 130 130 === select_col($table,$field,$conds=null) === 131 131 select a single field in table and return all values 132 @param string $table133 @param string $field name of the single field to retrieve134 @param mixed $conds135 @return array or FALSE132 - @param string $table 133 - @param string $field name of the single field to retrieve 134 - @param mixed $conds 135 - @return array or FALSE 136 136 {{{ 137 137 #!php … … 142 142 143 143 === select_slice($table,$fields='*',$conds=null,$pageId=1,$pageNbRows=10) === 144 This method is an helper to easily create page navigation for large result sets. 144 This method is an helper to easily create page navigation for large result sets.[[BR]] 145 145 You can configure the navigationStr with set_slice_attrs() method 146 @param string|array $table147 @param string|array $fields148 @param string|array $conditions149 @param int $pageId the page to query and return (start at 1)150 @param int $pageNbRows the max number of results by page.151 @return array array((array) results,(str) navigationstring, (int) totalrows) or false on empty results146 - @param string|array $table 147 - @param string|array $fields 148 - @param string|array $conditions 149 - @param int $pageId the page to query and return (start at 1) 150 - @param int $pageNbRows the max number of results by page. 151 - @return array array((array) results,(str) navigationstring, (int) totalrows) or false on empty results 152 152 {{{ 153 153 #!php … … 160 160 161 161 === query_to_array($Q_str,$result_type='ASSOC') === 162 return the result of a query to an array. 162 return the result of a query to an array.[[BR]] 163 163 Typically you will use this one for more advanced queries. 164 @param string $Q_str SQL query165 @param string $result_type 'ASSOC', 'NUM' et 'BOTH'166 @return array | false if no result164 - @param string $Q_str SQL query 165 - @param string $result_type 'ASSOC', 'NUM' et 'BOTH' 166 - @return array | false if no result 167 167 168 168 {{{ … … 177 177 === get_count($table,$conds=null) === 178 178 get the number of row in $table 179 @param string $table table name180 @param mixed $conds181 @return int179 - @param string $table table name 180 - @param mixed $conds 181 - @return int 182 182 {{{ 183 183 #!php … … 188 188 189 189 === associative_array_from_q2a_res($index_field='id',$value_fields=null,$res = null,$keep_index=FALSE,$sort_keys=FALSE) === 190 return an associative array indexed by $index_field with values $value_fields from a db->select_rows result. 190 return an associative array indexed by $index_field with values $value_fields from a db->select_rows result.[[BR]] 191 191 Most of the time you will preferably use db->select_associative in place of this one. 192 @param string $index_field default value is id193 @param mixed $value_fields (string field name or array of fields name default is null so keep all fields194 @param array $res the mysqldb->select_rows result195 @param bool $keep_index if set to true then the index field will be keep in the values associated (unused if $value_fields is string)196 @param bool $sort_keys will automaticly sort the array by key if set to true @deprecated argument197 @return array192 - @param string $index_field default value is id 193 - @param mixed $value_fields (string field name or array of fields name default is null so keep all fields 194 - @param array $res the mysqldb->select_rows result 195 - @param bool $keep_index if set to true then the index field will be keep in the values associated (unused if $value_fields is string) 196 - @param bool $sort_keys will automaticly sort the array by key if set to true @deprecated argument 197 - @return array
