Procedural File: datalib.php
Source Location: /datalib.php
Page Details:
Includes:
build_filter [line 83]
void build_filter(
array $filter, &$select &$values, &$values 2)
|
|
Converts name/values pairs into an an SQL where clause.
Parameters
&$values |
2 |
References an array to hold the parameters. |
array |
$filter |
Array of name/value pairs. |
&$select |
&$values |
References a string to hold the query. |
count_records [line 112]
integer count_records(
string $table, [array $filter = ""])
|
|
Returns the number of records that match the conditions. Parameters:
Tags:
Parameters
string |
$table |
The name of the database table |
array |
$filter |
An array of field name/value pairs. |
delete_records [line 269]
boolean delete_records(
string $table, array $filter)
|
|
Deletes one or more database records
Tags:
Parameters
string |
$table |
The name of the database table |
array |
$filter |
An array of field name/value pairs |
execute_sql [line 41]
any execute_sql(
string $command, [boolean $wantResult = false], [boolean $feedback = false], [boolean $dieOnError = false])
|
|
Executes the provided SQL command and optionally returns the results.
Tags:
Parameters
string |
$command |
The SQL command to execute |
boolean |
$wantResult |
Flag to return the results |
boolean |
$feedback |
Flag to show result to user |
boolean |
$dieOnError |
Flag to abort script on failure |
get_field [line 217]
any get_field(
string $table, $return, $return $filter)
|
|
Get a single field from a record.
Tags:
Parameters
string |
$table |
The name of the database table |
$return |
$filter |
The field/column value to return. |
|
$return |
|
get_record [line 143]
object The get_record(
string $table, array $filter)
|
|
Lookups a record using a filter and returns it as a standard object. If more than one record matches, only the first is returned.
Tags:
Parameters
string |
$table |
The name of the database table |
array |
$filter |
An array of field name/value pairs. |
get_records [line 182]
object The get_records(
string $table, [array $filter = ""], [string $sort = ""], [string $fields = "*"], [integer $limitfrom = 0], [integer $limitcount = 0])
|
|
Gets zero or many records from a table as an array of objects with optional filtering, sorting, list of fields and limits. NOTE: This function can be more efficient by using the native database LIMIT/OFFSET options, however they are not portable and the details differ from one database server to another. This function will use a lot of memory on large datasets.
Tags:
Parameters
string |
$table |
The name of the database table |
array |
$filter |
An array of field name/value pairs. |
string |
$sort |
The optional sort sequence. |
string |
$fields |
An optional list of record fields. |
integer |
$limitfrom |
An optional offset to the first record. |
integer |
$limitcount |
An optional limit on number of records returned. |
insert_record [line 322]
boolean insert_record(
string $table, object $dataobject, [boolean $returnid = false])
|
|
Creates a new database record from an object.
Tags:
Parameters
string |
$table |
The name of the database table |
object |
$dataobject |
A standard object holding the record values |
boolean |
$returnid |
Flag to return the inserted record's primary key |
record_exists [line 71]
boolean record_exists(
string $table, array $filter)
|
|
Determine if a record matching up to 3 filter conditions exists or not.
Tags:
Parameters
string |
$table |
The database table/view name |
array |
$filter |
An array of field name/value pairs. |
reportError [line 20]
void reportError(
PDOException $error)
|
|
Record a PDO error message to the log file.
Parameters
PDOException |
$error |
A PDO exception object. |
set_field [line 245]
boolean set_field(
string $table, string $setfield, any $newvalue, array $filter)
|
|
Updates one field in a database record.
Tags:
Parameters
string |
$table |
The name of the database table |
string |
$setfield |
The field in the record to change |
any |
$newvalue |
The field's new value |
array |
$filter |
An array of field name/value pairs |
table_info [line 295]
array table_info(
string $table)
|
|
Helper function to retrieve information about a table's columns.
Tags:
Parameters
string |
$table |
Name of the table in the database. |
update_record [line 374]
boolean update_record(
string $table, object $dataobject, [string $primarykey = "id"])
|
|
Issues an UPDATE statement with modified record values.
Tags:
Parameters
string |
$table |
Name of the database table. |
object |
$dataobject |
A PHP object with the new record values. |
string |
$primarykey |
The name of the primary key column. |
|
|