DB utility class. More...
Public Member Functions | |
| __construct ($adapter) | |
| Class constructor. | |
| connect () | |
| Connect to the database. | |
| select () | |
| Select the database. | |
| close () | |
| Close the connection. | |
| escape ($item) | |
| Escape the string to make it safe. | |
| execute ($sql, $data=array(), $options=array()) | |
| Execute a statement, with provided variables. | |
| record ($sql, $data=array(), $options=array()) | |
| Fetch the first row of a query as associative array. | |
| records ($sql, $data=array(), $options=array()) | |
| Fetch all rows of a query as an associative array. | |
| first ($sql, $data=array(), $options=array()) | |
| Fetch the first row of a query as an object. | |
| all ($sql, $data=array(), $options=array()) | |
| Fetch all rows of a query as an array of objects. | |
| value ($sql, $data=array(), $options=array()) | |
| Fetch the first value of the first column from a query. | |
| values ($sql, $data=array(), $options=array()) | |
| Fetch the first column values for each row from a query as an array. | |
| count ($sql, $data=array(), $options=array()) | |
| Count the rows returned by a query. | |
| get_last_id () | |
| Get the id from the last INSERT statement. | |
| errors ($sql='') | |
| return errors from last PDO statement. | |
| is_table ($table_name, $database='') | |
| Check the table exists. | |
| query ($options=array()) | |
| run a query | |
| build_sql ($options=array(), &$data=array()) | |
| Build SQL from query options (where, order_by, limit etc.);. | |
| replace ($table_name, $data, $options=array()) | |
| Insert/update a record using REPLACE. | |
| insert ($table_name, $data) | |
| Insert a record using INSERT. | |
| update ($table_name, $data, $primary_field, $primary_value=null) | |
| Update a record using UPDATE. | |
| delete ($table_name, $where=array()) | |
| Delete records matching criteria. | |
| execute_script ($file_name) | |
| Execute a SQL script from a file. | |
| parse_where ($where, &$data=array()) | |
| Parse the WHERE conditions of a SQL query or statement from array of data. | |
| parse ($sql, $data=array()) | |
| Parse parameters. | |
Public Member Functions inherited from Base | |
| __call ($function, $params) | |
| The 'magic' call method will get/set for us invoked when the interpreter can not find a method the user is asking for. | |
| set_parameters ($arguments) | |
| Set variables from an array to member fields requires $this->optional_arguments or $this->required_arguments to have been set by the subclass. | |
Protected Attributes | |
| $adapter = '' | |
| DB connection. | |
| $last_sql = '' | |
| Last SQL string executed. | |
| $last_data = '' | |
| DB connection. | |
Protected Attributes inherited from Base | |
| $optional_arguments = array() | |
| Array of options that can be set to variables. | |
| $required_arguments = array() | |
| Array of options that need to be set to variables. | |
DB utility class.
Creates a connection to the database using adapter objects, constructs and executes statements
| Db::__construct | ( | $adapter | ) |
Class constructor.
Sets adapter.
1.8.1.1