$db
$db :
The PDO database object.
A simple, lightweight DB class.
__construct(Mixed $conf, Bool $keep_config = false)
Build our DB\Simple object.
| Mixed | $conf | The database configuration. |
| Bool | $keep_config | Save the database configuration. Default: false. The $conf may be either a JSON string, a JSON filename, or an Array. The Array must contain at least a 'dsn' member. If the database uses a username and password, it must also contain 'user' and 'pass' members. If the database has a unique server_id, then it should be specified as the 'sid' member. The database name will be extracted from the DSN either as the 'dbname' property, or as the SQLite filename. If $keep_config is true, then the configuration is stored in the protected $db_conf property. |
select(Mixed $table, Array $opts = array())
Perform a SELECT query.
| Mixed | $table | The database table(s) we are querying against. |
| Array | $opts | (Optional) An associative array of options. The $table may be either a String, or an Array. If it is an Array, the tables will be joined using a comma. The $opts can contain any of the following optional parameters: 'where' The WHERE statement. Can be a string or associative array. 'data' If 'where' is a string, this contains the placeholder data. This is not used at all if 'where' is an associative array. 'cols' The columns to return. Defaults to '*'. 'order' The ORDER BY statement: e.g. "timestamp DESC, name ASC" 'limit' The LIMIT statement. 'offset' The OFFSET statement (only used with 'limit'). 'single' If set to true, it explicitly sets LIMIT 1, and returns the row data rather than the statement object. 'fetch' Change the PDO Fetch Mode. Default: PDO::FETCH_ASSOC. |
update(String $table, Mixed $where, Array $cdata, Array $wdata = null)
Save an existing row.
| String | $table | The table to insert the data into. |
| Mixed | $where | The WHERE statement. |
| Array | $cdata | The columns we are updating. |
| Array | $wdata | The WHERE placeholder data (see below.) If $where is an Array, then it's a standalone WHERE clause, and the $wdata parameter is not needed (and will be ignored.) If $where is a string, then $wdata must contain the placeholder data for the WHERE statement. |