sql sql(
[
$type = ""], [
$dbase = ""], [
$host = ""], [
$user = ""], [
$pass = ""]
)
|
|
Parameters:
|
|
$type: |
|
|
|
$dbase: |
|
|
|
$host: |
|
|
|
$user: |
|
|
|
$pass: |
|
Gets the number of affected rows
string build_delete(
array
$q
)
|
|
A function to build select queries. After compiling the query it is stored internally, so we can use it when calling query()
Example 1:
// Initialize the sql object. $database = new sql();
$qry = array(); $qry['delete'] = "inventory"; $qry['where'][] = "uid=100"; $qry['limit'] = "3";
// build and execute query.. $database->build_delete($qry); if($database->query()) { echo "<p>deleted!</p>"; } else { echo "<p>not deleted!</p>"; }
Parameters:
API Tags:
| Return: | the compiled query |
string build_insert(
array
$q
)
|
|
A function to build select queries. After compiling the query it is stored internally, so we can use it when calling query()
Example 1:
// Initialize the sql object. $database = new sql();
$qry = array(); $qry['into'] = "employees"; $qry['value']['firstname'] = "Henk"; $qry['value']['lastname'] = "de Vries";
// build and execute query.. $database->build_insert($qry); if($database->query()) { echo "<p>updated!</p>"; } else { echo "<p>not updated!</p>"; }
Parameters:
API Tags:
| Return: | the compiled query |
void build_save_on_uid(
$values,
$uid_field,
$table
)
|
|
Build either an insert or an update to save the values
Parameters:
|
|
$values: |
|
|
|
$uid_field: |
|
|
|
$table: |
|
API Tags:
string build_select(
array
$q
)
|
|
A function to build select queries. After compiling the query it is stored internally, so we can use it when calling query()
Example 1:
// Initialize the sql object. $database = new sql();
// Simple select query instruction: $qry = array(); $qry['select'] = "*"; $qry['from'] = "employees"; $qry['where'][] = "firstname LIKE 'b%'";
// build and execute query.. $database->build_select($qry); $database->query();
$rows = $database->fetch_all_rows();
Example 2:
// Initialize the sql object. $database = new sql();
// Simple select query instruction: $qry = array(); $qry['select'] = "employees.*, inventory.*, computers.*"; $qry['from'] = "inventory"; $qry['leftjoin']['employees'] = "employees.uid = inventory.employee_uid"; $qry['leftjoin']['computers'] = "computers.uid = inventory.employee_uid"; $qry['limit'] = "3";
// build and execute query.. $database->build_select($qry); $database->query();
$rows = $database->fetch_all_rows();
Parameters:
API Tags:
| Return: | the compiled query |
string build_update(
array
$q
)
|
|
A function to build select queries. After compiling the query it is stored internally, so we can use it when calling query()
Example 1:
// Initialize the sql object. $database = new sql();
$qry = array(); $qry['update'] = "inventory"; $qry['value']['amount'] = "(RAND())*100"; $qry['where'][] = "uid=100";
// build and execute query.. $database->build_update($qry); if($database->query()) { echo "<p>updated!</p>"; } else { echo "<p>not updated!</p>"; }
Parameters:
API Tags:
| Return: | the compiled query |
Set up the Database connection, depending on the selected DB model.
void error(
[string
$error_msg = ""], string
$sql_query, string
$error_no
)
|
|
If an error has occured, we print a message. If 'halt_on_sql_error' is set, we die(), else we continue.
Parameters:
|
string |
$error_msg: |
|
|
string |
$sql_query: |
|
|
string |
$error_no: |
|
array fetch_all_rows(
[string
$getnames = "with_names"]
)
|
|
Fetch all rows from the last results.
Parameters:
API Tags:
array fetch_row(
[string
$getnames = "with_names"]
)
|
|
Fetch a single row from the last results.
Parameters:
API Tags:
void get_last_id(
none
0
)
|
|
Get the last inserted id
Parameters:
void get_last_query(
none
0
)
|
|
Get the last performed or stored query
Parameters:
string get_server_info(
)
|
|
Gets the current MySQL version
boolean is_mysql_function(
string
$str
)
|
|
Checks if the parameter is an mysql function or not. used to determine whether or not a parameter needs to be escaped.
$this->is_mysql_function("some value"); // returns true
$this->is_mysql_function("some value"); // returns true
Parameters:
Gets the number of selected rows
void query(
[string
$query = ""]
)
|
|
Performs a query. Either pass the query to e executed as a parameter,
Parameters:
Returns the number of executed queries
string quote(
string
$value, [boolean
$skipquotes = false]
)
|
|
Quote variable to make safe to use in a SQL query. If you pass $skipquotes as true, the string will just have added slashes, otherwise it will be wrapped in quotes for convenience
Parameters:
|
string |
$value: |
to quote |
|
boolean |
$skipquotes: |
to skip adding quotes |
API Tags:
void set_allow_functions(
boolean
$value
)
|
|
Set if we're allowed to use MySQL functions in our queries. This is disabled by default, for security reasons.
Parameters:
void set_halt_on_error(
boolean
$value
)
|
|
Sets whether or not execution of the script should stop when a mysql error has occured.
Parameters: