Member Function Documentation
| addWhere |
( |
$ |
sql, |
|
|
$ |
mode = 'AND' |
|
) |
| |
Add a subclause to the main WHERE clause of the query
- Parameters:
-
- Returns:
- self
Returns a single field from every line, resulting in an array of values (ie some kind of "vertical" fetching)
Note: this is different from as_whole, since only ONE value is present in each line
- Deprecated:
- Since:
- 20100216
- Version:
- 1.0
- Author:
- greg
- Parameters:
-
| $field | string, the field to extract on each line |
- Returns:
- array, all the values
| as_line |
( |
$ |
row_number = null | ) |
|
Returns the asked line as an array
You can either ask for the next line (no parameter) or given a row number in the result.
Note: the row number is based on the result, it may not be same as the row number in the complete table
- Deprecated:
- Since:
- 3.0
- Version:
- 1.0.1
- Author:
- greg
- Date:
- 20100810 (v1.0.1) (greg) return null if the resultset is empty
- Parameters:
-
| integer | $row_number | (optional) |
- Returns:
- array| null, the line or null if the resultset is empty
| as_one |
( |
$ |
row_number = null, |
|
|
$ |
field = null |
|
) |
| |
Return one value from the asked field of the asked line
- Deprecated:
- Since:
- 3.0
- Version:
- 1.0.3
- Author:
- greg
- Date:
- 20100620 (v1.0.1) (greg) made parameters optional (no "field" means first field)
-
20100630 (v1.0.2) (greg) object's focus is used if "$field" parameter is empty
-
20100810 (v1.0.3) (greg) return null if the resultset is empty
- Parameters:
-
| integer | $row_number | (optional) |
| string | $field | field name (optional) |
- Returns:
- string | null
Returns all lines from the result as a big array of arrays
- Deprecated:
- Since:
- 20100216 (v1.0) (greg)
-
20100428 (v1.1) (greg) use the focus parameter; use the smart key
-
20100607 (v1.2) (greg) renamed compact to focus, use the noEmptyRow/single_line parameters
- Version:
- 1.1
- Author:
- greg
- Returns:
- array, all the lines as arrays
Returns a single field from every line, resulting in an array of values (ie some kind of "vertical" fetching)
Note: this is different from as_whole, since only ONE value is present in each line
- Since:
- 20100216
- Version:
- 1.0.1
- Date:
- 20110816 (v1.0.1) (greg) added a count field
- Author:
- greg
- Parameters:
-
| $field | string, the field to extract on each line |
- Returns:
- array, all the values
| asLine |
( |
$ |
row_number = null | ) |
|
Returns the asked line as an array
You can either ask for the next line (no parameter) or given a row number in the result.
Note: the row number is based on the result, it may not be same as the row number in the complete table
- Since:
- 3.0
- Version:
- 1.0.1
- Author:
- greg
- Date:
- 20100810 (v1.0.1) (greg) return null if the resultset is empty
- Parameters:
-
| integer | $row_number | (optional) - NOT USED ANYMORE |
- Returns:
- array| null, the line or null if the resultset is empty
| asOne |
( |
$ |
row_number = null, |
|
|
$ |
field = null |
|
) |
| |
Return one value from the asked field of the asked line
- Since:
- 3.0
- Version:
- 1.0.4
- Author:
- greg
- Date:
- 20100620 (v1.0.1) (greg) made parameters optional (no "field" means first field)
-
20100630 (v1.0.2) (greg) object's focus is used if "$field" parameter is empty
-
20100810 (v1.0.3) (greg) return null if the resultset is empty
-
20110908 (v1.0.4) (greg) fixed a bug when dealing with an empty result line
- Parameters:
-
| integer | $row_number | (optional) |
| string | $field | field name (optional) |
- Returns:
- string | null
Returns all lines from the result as a big array of arrays
- Since:
- 20100216 (v1.0) (greg)
-
20100428 (v1.1) (greg) use the focus parameter; use the smart key
-
20100607 (v1.2) (greg) renamed compact to focus, use the noEmptyRow/single_line parameters
- Version:
- 1.1
- Author:
- greg
- Returns:
- array, all the lines as arrays
| build |
( |
$ |
parameters = null | ) |
|
Build the query based on the private sql and the parameters
- Since:
- 20100216
-
20100428 (v1.0.1) (greg) use sql() instead of sql
- Date:
- 20100630 (v1.0.2) (greg) use array_compact to avoid null values
- Version:
- 1.0.2
- Author:
- greg
- Parameters:
-
| $parameters | (optional)array, the parameters to inject into the query |
- Returns:
- string, the sql query string
| checkParameters |
( |
&$ |
parameters = null | ) |
|
Allows daughter classes to check the parameters array before the query is sent
- Parameters:
-
| $parameters | array, the unprotected parameters |
- Returns:
- boolean true is it's ok to sent, false otherwise
| checkResults |
( |
&$ |
results = null | ) |
|
Allows daughter classes to check the results array before it's sent back
- Parameters:
-
| $parameters | array, the unprotected results |
- Returns:
- boolean true is it's ok to sent, false otherwise
| connector |
( |
$ |
connector = null | ) |
|
Get and/or set the actual connector instance
Note: can only be set if it was not set before
- Parameters:
-
| PHPDS_dbConnector | string | $connector | |
- Returns:
- PHPDS_dbConnector
Return the number of lines in a result
- Since:
- 20100216
- Version:
- 2.0
- Date:
- 20110816 (v2.0) (greg) changed not use a call to the connector since a PDO might give a wrong result
- Author:
- greg
- Returns:
- integer, the number of rows, or -1 if it cannot be evaluated
| debugInstance |
( |
$ |
domain = null | ) |
|
The private debug instance of this object (with domain selection)
Reimplemented from PHPDS_dependant.
| extra_build |
( |
$ |
parameters = null | ) |
|
Construct the extra part of the query (WHERE ... GROUP BY ... ORDER BY...) Doesn't change $this->sql
- Deprecated:
- Parameters:
-
- Returns:
- string (sql)
- Version:
- 1.0
- Author:
- greg
| extraBuild |
( |
$ |
parameters = null | ) |
|
Construct the extra part of the query (WHERE ... GROUP BY ... ORDER BY...) Doesn't change $this->sql
- Parameters:
-
- Returns:
- string (sql)
- Version:
- 1.0
- Author:
- greg
Try to figure out which is the key field.
- Deprecated:
- Parameters:
-
| array | $row,a | sample row to study |
- Returns:
- string (or null), the key field name
- Version:
- 1.0
- Author:
- greg
Deal with all special cases (i.e flags) regarding how results should be returned
The special cases handled are these (in order of precedence):
- returnId (instead of the actual result, last_id is returned)
- single_value (only the first value is returned as a scalar)
- singleRow (the first row is returned as a an one-dimension array)
Cell-specific handling is done elsewhere
In the absence of special case, the whole result is returned as an array of arrays (by calling as_whole() )
- Deprecated:
- Version:
- 1.1
- Date:
- 20100610 (greg) (v1.0) added, based on Jason's work
-
20100617 (jason) (v1.0.1) added support for "string" setting
-
20100620 (greg) (v1.0.2) cleaned up using class methods
-
20100708 (greg) (v1.1) clean up with definitive API
- Returns:
- usually an array, although can be false, or int for an ID
Try to figure out which is the key field.
- Parameters:
-
| array | $row,a | sample row to study |
- Returns:
- string (or null), the key field name
- Version:
- 1.0
- Author:
- greg
Deal with all special cases (i.e flags) regarding how results should be returned
The special cases handled are these (in order of precedence):
- returnId (instead of the actual result, lastId is returned)
- singleValue (only the first value is returned as a scalar)
- singleRow (the first row is returned as a an one-dimension array)
Cell-specific handling is done elsewhere
In the absence of special case, the whole result is returned as an array of arrays (by calling as_whole() )
- Version:
- 1.1.1
- Date:
- 20100610 (greg) (v1.0) added, based on Jason's work
-
20100617 (jason) (v1.0.1) added support for "string" setting
-
20100620 (greg) (v1.0.2) cleaned up using class methods
-
20100708 (greg) (v1.1) clean up with definitive API
-
20110812 (greg) (v1.1.1) removed special "empty" case since only MySQL supports it
- Returns:
- usually an array, although can be false, or int for an ID
| invoke |
( |
$ |
parameters = null | ) |
|
The usual process of a query: check the parameters, send the query to the server, check the results
Return the results as an array (for SELECT queries), true for other successfull queries, false on failure
- Version:
- 1.1.1
- Date:
- 20100709 (greg) (v1.1.1) changed is_resource() to !empty() because it may return something else
- Parameters:
-
- Returns:
- array or boolean
Limits query.
- Parameters:
-
If the fields list has been set, construct the SELECT statement (or else do nothing)
- Version:
- 1.0.1
- Author:
- greg
- Date:
- 20100628 (v1.0.1) (greg) the build sql string replaces the obejct's sql field, instead of being appended
- Returns:
- nothing
| protect_array |
( |
array $ |
a | ) |
|
Protect a array of strings from possible hacker (i.e. escape possible harmfull chars)
- Deprecated:
- Since:
- 20100216
- Version:
- 1.0
- Author:
- greg
- Parameters:
-
| $a | array, the strings to protect |
- Returns:
- array, the same string but safe
| protectArray |
( |
array $ |
a, |
|
|
$ |
quote = '' |
|
) |
| |
Protect a array of strings from possible hacker (i.e. escape possible harmfull chars)
- Since:
- 20100216
- Version:
- 1.1
- Date:
- 20111010 (v1.1) (greg) added "quote" parameter
- Author:
- greg
- Parameters:
-
| $a | array, the strings to protect |
| $quote | string, the quotes to add to each non-numerical scalar value |
- Returns:
- array, the same string but safe
| protectString |
( |
$ |
string | ) |
|
Protect a strings from possible hacker (i.e. escape possible harmfull chars)
- Since:
- 20101109
- Version:
- 1.0
- Author:
- Jason
- Parameters:
-
| string | the strings to protect |
- Returns:
- string the same string but safe
| query |
( |
$ |
parameters = null | ) |
|
Build and send the query to the database
- Since:
- 20100219
- Version:
- 1.0.3
- Date:
- 20110216 (greg) (v1.0.3) added a log of the sql + the class name
-
20110731 (greg) altered to use $this->querySQL
- Author:
- greg
- Parameters:
-
| mixed | $parameters | (optional)array, the parameters to inject into the query |
- Returns:
- void
FIrephp-specific debug display of the query
- Parameters:
-
Direclty send the query to the database
- Since:
- 20110731
- Version:
- 1.0
- Date:
- 20110731 (greg) added based on old $this->query
- Author:
- greg
- Parameters:
-
| string | $sql,the | sql request |
- Returns:
- void
| rows |
( |
$ |
parameters = null | ) |
|
Build a query combination of columns and rows specifically designed to write rows of data to the database.
- Since:
- 20100226
-
20100226
- Version:
- 1.0.0
- Parameters:
-
| array | Holds columns in the order they need to be written. |
Get/set actual sql string.
You may want to override this to alter the sql string as whole, and/or build it from various sources. Note this is only the first part of the query (SELECT ... FROM ...), NOT including WHERE, GROUP BY, ORDER BY, LIMIT
- Parameters:
-
| string | $sql | (optional) if given, stored into the object's sql string |
- Returns:
- string the sql text
- Version:
- 1.0
- Author:
- greg
| typeCast |
( |
$ |
values, |
|
|
$ |
key = null |
|
) |
| |
- Parameters:
-
- Returns:
- <type>
Field Documentation
$affectedRows = -1 [protected] |
$auto_protect [protected] |
$autoProtect = false [protected] |
$cachedResult [protected] |
$connector = null [protected] |
$groupby = '' [protected] |
$keyField = '' [protected] |
$no_empty_row [protected] |
$noEmptyRow = false [protected] |
$orderby = '' [protected] |
$returnId = false [protected] |
$rowCount = -1 [protected] |
$single_value [protected] |
$singleRow = false [protected] |
$singleValue = false [protected] |
The documentation for this class was generated from the following files: