PVDatabase

Extends \PVStaticObject

PVDatabase controls the connections to various databases ranging from Mysql to MongoDB.

For future development, the class needs to be written, but it offers a lot of powerful features that including prepared statements, schema manipulation, sanitization, and other features.

Example:

//Initialize the class
PVDatabase::init();

//Two Different Configurations
$mysql_options = array(
    'dbhost' => 'localhost',
    'dbuser' => 'jondoe',
    'dbpass'=>'abc123',
    'dbtype'=>'mysql',
    'dbname'=>'example1',
    'dbport'=>3306
);

//Add The Connection
PVDatabase::addConnection('connection1', $mysql_options);

$postgres_options = array(
    'dbhost' => 'localhost',
    'dbuser' => 'janedoe',
    'dbpass'=>'doeraeme',
    'dbtype'=>'postgresql',
    'dbname'=>'example2',
    'dbport'=>5432
);

//Add The Connection
PVDatabase::addConnection('connection2', $postgres_options);

//Connect To the Mysql Database
PVDatabase::setDatabase('connection1');

//Sanitize input
$value = PVDatabase::makeSafe('SELECT ItemName, ItemDescription FROM Items WHERE ItemNumber = 999; DROP TABLE USERS ');

//Execute A Query
PVDatabase::query("INSERT INTO users(name) VALUES(${value})");

//Change the Database connection
PVDatabase::setDatabase('connection2');
todo

break apart class into seperate database handlers

package

system

Methods

Uses the magic method __call and executes a closure/anonymous function that has been added to the classes $_methods using the addMethod() method.

__callStatic(string $method, mixed $args = array()) : mixed
inherited static
access

public

Arguments

$method

string

The key/name assigned to the method when added

$args

mixed

Arguements to pass to the annoymous function. The function is called using call_user_func_array.

Response

mixed

$value The value returned is the value the stored function returns

Apply a fitler if filter is set.

_applyFilter(string $class, string $method, mixed $data, array $options = array()) : mixed
inherited static
access

protected

Arguments

$class

string

The name of the class the filter is in

$method

string

The method the filter is in

$data

mixed

The data that is being passed to the filter

$options

array

options to be passed to the filter. Passed options we be passed to the function. -'default_return' mixed: If no filter is return, the data passed in by default will be return. Can be overriden -'event' string: An event to associate with the filter. Default is null

Response

mixed

$data The data the function returns

Calls an adapter for this class. The easiest way of implementing an adapter is by placing the adapter at the top of the function that it is being called in. An infinite amout of parameters can be passed to the adapter BUT the parameters should be the same as the parents.

_callAdapter(string $class, string $method) : mixed
inherited static
access

protected

Arguments

$class

string

The name of the class the adapter is in

$method

string

THe name of the method the class is being called from.

Response

mixed

$value A value that the adapter returns

Checks if an adapter is set for the function.

_hasAdapter( $class, string $method) : \boolea
inherited static
access

protected

Arguments

$class

$method

string

The associated method

Response

\boolea

$hasAdapter Returns true if it has an adapter or false if it doesn not

Checks if a filter has been set.

_hasFilter(string $class, string $method) 
inherited static

Arguments

$class

string

The class the filter is in

$method

string

The method of the class that the filter is in

Calls a methods that is an instance of an class. This method is generally faster than using user_call_func_array.

_invokeMethod(string $class, string $method, array $args) : mixed
inherited static
access

protected

Arguments

$class

string

The name of the class to be called

$method

string

The name of the method in the class to be called

$args

array

An array of arguements. Arguements have to be embedded in an array to be called.

Response

mixed

$data Data returned by the function called

Calls a methods that is a static method of a class. This method is generally faster than using user_call_func_array.

_invokeStaticMethod(string $class, string $method, array $args) : mixed
inherited static
access

protected

Arguments

$class

string

The name of the class to be called

$method

string

The name of the method in the class to be called

$args

array

An array of arguements. Arguements have to be embedded in an array to be called.

Response

mixed

$data Data returned by the function called

Write out the contents of adapters used to a log

_logAdapter(array $data) : void
inherited static
access

private

Arguments

$data

array

The data in the adapter

Write out the contents of a filter used to a log

_logFilter(array $data) : void
inherited static
access

private

Arguments

$data

array

The data in the filter

Write out the contents of an observer to a log.

_logObserver(array $data) : void
inherited static
access

private

Arguments

$data

array

The data in the observer

Calls any functions that have been added to the observer if the event is present in the observers array.

_notify(string $event) : void
inherited static
access

protected

Arguments

$event

string

The name of the even that occured that will trigger notifies

Breaks down the data to be logged from an adapter, filter or observer.

_prepareLogData(array $data) : string
inherited static
access

private

Arguments

$data

array

Response

string

$message JSON encode message of information about the data

Sets the current MongoDB collection to use

_setMongoCollection(string $table_name, array $options = array()) : object
static

Arguments

$table_name

string

Not really a table but a collection in a Mongo Database

$options

array

Options to pass to Mongo collection

  • boolean gridFS Default is false, but if set to true, will use gridFS

Response

object

The collection

Adapters allows a method to be completely overwritten by calling a different class with the same method name. Adapters can also be used with closures. The adapter uses a strategy/adapter design pattern.

addAdapter(string $trigger_class, string $trigger_method, string $call_class, array $options = array()) : void
inherited static
access

public

todo

add ability to adapt singleton class

Arguments

$trigger_class

string

The class that contains the function the adapter will respond too

$trigger_method

string

The method called that will have the adapter to be called.

$call_class

string

The new class to be called that has the same method name

$options

array

An array of options that be called -'object' string : Assumes that default method in the class to be called is static. If called object needs to be instantiated, change to object to 'instance' and one will be created before the adapter calls the function -'call_method' string: By default the method to be called to override the current one should be the same name. But this can be ovveridden to call a different method. -'type' string: The type of method being called. Default is class_method but if the method is a closure, set the type to be 'closure' and make the $trigger_method the closure

Will add an adapter for every method in the trigger_class to another class. The method will only be adapted to another class if the method in the trigger class has an adapter. This functionality can be very similiar to DI.

addClassAdapter(mixed $trigger_class, string $call_class, array $options = array()) : void
inherited static
access

public

todo

Add ability to use singleton classes

Arguments

$trigger_class

mixed

This can either be the name of the class or an object whose methods will be adapted to another class. The class should be included or be autoloaded by this point.

$call_class

string

The call class is the classes methods that will be called in place of the methods in the trigger_class. These class does not have to be included as this point.

$options

array

Options that be used to further distinguish the behavior of the adapters added -'object' string: Determines if the object being adapted to is static or an instance.Default is static -'call_class' string: The name of the class that the methods will be adapted too. -'class' string: The name of the whose methods will be adapted to another class

Adds a columns to a table that already exist.

addColumn(string $table_name, string $column_name, array $column_data = array(), array $options = array()) : string
static
access

public

Arguments

$table_name

string

The name of the table that the column will be added too

$column_name

string

The name of the column to be adding to the table

$column_data

array

The data that will define the column to be created. The array should contain the same information would would be passed too formatColumn (@see formatColumn).

$options

array

Options that define how adding a column operates. -'format_table' boolean: Formats the table name by adding the prefix set in the database config. Default is false. -'execute' boolean: Execute the query to create the table. Default is true. -'return_query' bolean: Return the generated query. Default is true;

Response

string

$query Returns the query for creating the table name

Add a connection to the database class. The connection can be later used by calling the function PVDatabase::setDatbase().

addConnection(mixed $connection_name, array $args) : void
static

Example

$connection=array( 'dbhost'=>'localhost', 'dbuser'=>'admin', 'dbpass'=>'abc123' 'dbname'=>'mydb', 'dbtype'=>'postgresql' );

PVDatabase::addConnection('connection_1',$connection);

access

public

Arguments

$connection_name

mixed

Connection name can either be a string or integer.

$args

array

And array that contains the information for connecting to the database.

  • 'dbhost' string: The host or ip the database is on
  • 'dbuser' string: The username to connected to the database
  • 'dbpass' string: The password the user uses to connect to the database
  • 'dbtype' string: The type of database. Options are mysql - postgresql -mssql
  • 'dbname' string: The name of the database on the host
  • 'dbport' string: Optional. The port that is used to connect to the database
  • 'dbschema' string: Optional. The schema the database is on (generally used in PostgreSQL)
  • 'dbprefix' string: Optional. A prefix that will be placed in front of every table.

Adds a filter to the class. Filters are for modifying a value within a class and should not interpet the normal flow within the method.

addFilter(string $class, string $method, string $filter_class, string $filter_method, array $options = array()) : void
inherited static
access

public

Arguments

$class

string

The name of the class the filter is going in

$method

string

The name of the method the filter is in

$filter_class

string

The class that the filter resides in.

$filter_method

string

The method in the class that the parameters will be passed too.

$options

array

Options that can be set for further modifying the filter. -'object' string: If the method being called is static, static should be inserted. If its in an instance, 'instance' should be set. Default is set to static. -'event' string: Associate this filter with an event. -'type' string: The type of function being called. Default is class_method but if the function is a closure, set the type to be 'closure' and make the $filter_method the closure

Adds a closure/anonymous function to the object that can be called.

addMethod(string $method, \function $closure) : void
inherited static
access

public

Arguments

$method

string

The key/value that will be used to call the function

$closure

\function

The anonymous function/closure to be added

Adds an observer to the class. Observer events can fired in any method to trigger a response.

addObserver(string $event, string $class, string $method, array $options = array()) : void
inherited static
access

public

Arguments

$event

string

The name of the event that will cause a certain class and method to fire

$class

string

The name of the class that contains the function that will be fired for this event

$method

string

The name of the method that will be fired when the event occurs

$options

array

Options to further the define the firing of an event -'object' string : If the method being called is static, should be set to static. Else set to instance -'class' stinrg : The name of the class to be called. Default is the class that is passed in. -'method' string: The name of the method to be called. Default is the method that is passed in. -'type' string: The type of function being called. Default is class_method but if the function is a closure, set the type to be 'closure' and make the $method the closure

Adds a data to the public collection, index will be assigned automatically. Primarily used for adding launch quanties of data to the collection

addToCollection(mixed $data) : void
inherited static
access

public

Arguments

$data

mixed

Any data type( Object, Array, int, etc) to add to the public data collection

Adds data to the public collection. The data is assigned a key/index. If the key/index is already set, new information will override the old one.

addToCollectionWithName(string $name, mixed $data) : void
inherited static
access

public

todo

check the relevance of get and set

Arguments

$name

string

The key/index to assign the value to

$data

mixed

Data to be stored in the collection

For prepared statements, binds the parameters with placeholders.

bindParameters(string &$statement, array &$params) 
static

Arguments

$statement

string

The sql statement

$params

array

The parameters to bind with

Not sure what this function does

catchDBError() 
static
todo

dig into the function and redo

Remove all the filters from a class.

clearFilters(string $class, string $method) : void
inherited static
access

public

Arguments

$class

string

The class the filter is in

$method

string

The method of the class that the filter is in

Removes all the observers assoicated with an event.

clearObservers(string $event) : void
inherited static
access

public

Arguments

$event

string

The event to remove all the observers from

Truncates/Removes all information from a table.

clearTableData(string $tablename, string $options = '') : void
static
access

public

Arguments

$tablename

string

The name of the table to clear

$options

string

Options to be added at the end of the SQL query

Closes a database connection depending on the connection that has been set

closeDB() : void
static
access

public

Checkes if a column exist with a table. Make sure to enter the schema.table_name if needed.

columnExist(string $table_name, string $field_name) : boolean
static

Example: if(!PVDatabase::columnExist('test.contacts', 'first_name' )){ //Code to create table }

Arguments

$table_name

string

The name of the table to be checked

$field_name

string

The name of the column to check if exist

Response

boolean

$exist Returns true if exist, otherwise return false

Maps the column type depending on which database is set. For example, is the database is mysql and the type string is passed through, the return value is varchar. If the database is postgresql, the return type would be character varying.

columnTypeMap(string $type) : string
static
access

public

Arguments

$type

string

The type of variabel to be matched

Response

string

$match The matched type found

Connect the that database based on the creditionals in the PHP file.

connect() : void
static
access

private

Create a table in the database in which the connection is currently set too.

createTable(string $table_name, array $columns = array(), array $options = array()) : string
static
access

public

Arguments

$table_name

string

The name of the to be created

$columns

array

The columns that are to be created with the table. The syntax for creating the columns are from @see formatColumn. The column name is the key and parameters that create the column is the array that will be passed to formatColumns

$options

array

Options that control the creation of a table. -'format_table' boolean: Formats the table by adding the table prefix set in the database configuration. Default is false. -'execute' boolean: Execute the query to create the table. Default is true. -'return_query' boolean: Returns the query that would create the table. Default is true -'primary_key' string: The primary key(s) of the table

Response

string

$query The return query to create the table or false

The average function is a function used to get the averge of fields in a database. This function returns the AVG function for the set database.

dbAverageFunction( $field) : \:
static

Example: $query="SELECT ".PVDatabase:::dbAverageFunction('age')." as average_age FROM Table

Arguments

$field

Response

\:

string average_function: The function needed to get the average value ina SQL string

Deletes an item from the database

deleteStatement(array $args, array $options = array()) : object
static

Arguments

$args

array

Arguements that define how the query will be created

$options

array

Options that define how the query will run

Response

object

$result The result of the query

Remove a column from a table in the database.

dropColumn(string $table_name, string $column_name, array $options = array()) : string
static
access

public

Arguments

$table_name

string

The name of the table to remove the column from

$column_name

string

The name name of the column to be removed

$options

array

Options that define how removing a column operates. -'format_table' boolean: Formats the table name by adding the prefix set in the database config. Default is false. -'execute' boolean: Execute the query to remove the column. Default is true. -'return_query' bolean: Return the generated query. Default is true;

Response

string

$query Returns the query for removing the column

Drops a table in the database

dropTable(string $table_name, array $options = array()) : string
static
access

public

Arguments

$table_name

string

The name of the table to be dropped

$options

array

Options that define how to remove the table -'format_table' boolean: Formats the table name by adding the prefix set in the database config. Default is false. -'execute' boolean: Execute the query to the table. Default is true. -'return_query' bolean: Return the generated query. Default is true;

Response

string

$query Returns the query for dropping the stable

Fetches the data in each row retrieved from a result. Results are retuned as array

fetchArray( $result) : array
static

Example: $result=PVDatabase::query('SELECT title, description FROM TABLE'); while($row=PVDatabase::fetchArray($result)){ echo $row['title']; }

Arguments

$result

Response

array

row: An assoctive array of a row from a table

Fetches the data in each row retrieved from a result. The results are compiled into an object and returned.

fetchFields(object $result) : array
static

Example: $result=PVDatabase::query('SELECT title, description FROM TABLE'); while($row=PVDatabase::fetchArray($result)){ echo $row['title']; }

Arguments

$result

object

A result from a query object

Response

array

$row An assoctive array of a row from a table

Formats a column based up passed parameters. The formated column will be ready to enter in a SQL database.

formatColumn(string $name,  $options = array()) : string
static
access

public

Arguments

$name

string

The name of the column to be formated

$options

Response

string

$format The column will be returned with arguements formatted to the set database.

Data entered into the database sometimes has characters such as '/' added to it. This function will remove those characters

formatData( $string) : mixed
static

Example: $name=PVDatabase::formatData($row['name']); OR $row=PVDatabase::formatData($row);

Arguments

$string

Response

mixed

data: Data with database characters removed

Formats a table to the names conventions used by the current database set up. If the table prefix is set for the current connection, it will be appened to the name of the database. If the schema is set, that will be appeneded also.

formatTableName(string $table_name, boolean $append_schema = true, boolean $append_prefix = true) : string
static
access

public

Arguments

$table_name

string

The name of the table to be formated

$append_schema

boolean

Will append the schema to the table name

$append_prefix

boolean

Will append a prefix to the tablee, but behind the schema

Response

string

$table_name The name of the table with the values appened in front of it

Retrieves a value that is in the public data collection or was pass through by the set method.

get(string $index) : mixed
inherited static
access

public

Arguments

$index

string

The index to retrieve a value from

Response

mixed

$data The data that was stored at that index

Returns the method auto incremented based on the database that is set.

getAutoIncrement() : string
static
access

public

Response

string

$increment The auto increment method with is database dependent

Returns the name of the current connection being used in the database.

getConnectionName() : string
static
access

public

Response

string

$connection_name The name of the current connect

Returns the current databse being used.

getDatabaseType() : string
static

Response

string

database: The database being used

Returns the instance of a class. Used for implementing the singleton design pattern. Class will only be instantiated once.

getInstance() : object
inherited static
access

public

Response

object

$instance Returns the instance of a class.

Returns the iterator for iterating through the values stored in the classes collection.

getIterator() : \PVIterator
inherited static

Response

\PVIterator

$iterator The classes collection in an iteratable form

access public

Returns paginate values. This function handles pagination depending on the database being used.

getPagininationOffset(string $table, string $join_clause = '', string $where_clause = '', integer $current_page, integer $results_per_page = 20, string $order_by = '', string $fields = 'COUNT(*) as count') : array
static

Arguments

$table

string

The main table to call pagination from

$join_clause

string

Any tables that are joined in this query

$where_clause

string

Where SQL statement

$current_page

integer

The current page. All pages or done by pageNumber-1. 0 is the first page

$results_per_page

integer

The number of results to return per page

$order_by

string

How to order the results.

$fields

string

How to count the results, default is 'COUNT(*) as count'

Response

array

results: Returns the

The placeholder is a value in preared statements that is suppose to represent a value to replaced at exection. Placeholder change depending on the database.

getPreparedPlaceHolder(integer $count = 1) : \$string
static
access

public

Arguments

$count

integer

The placeholder spot. Used for postgresql

Response

\$string

The placeholder for the current database

Returns the schema that is being used for this database connection. A '.' will be appended to the name of the schema if one exist. Schemas are only necessary for postgresql and db2

getSchema(boolean $append_period = true) : string
static

Example: $table_name=PVDatabase::getSchema.'contacts'; $query="INSERT INTO $table_name(name, phone) VALUES('John Smith', '999-9999')"; PVDatabase::query($query);

access

public

Arguments

$append_period

boolean

Will appaned a period to the schema name

Response

string

$schema Returns the name of the current schema.

Returns the function for getting a random variable. The function returned is dependent on the database that is set.

getSQLRandomOperator() : string
static

Example: $query="SELECT * TABLE ORDER BY ".PVDATABASE::getSQLRandomOperator;

access

public

Response

string

$avg_function

Initializes the class.

init(array $config = array()) : void
static

Arguments

$config

array

Configuration options to pass into the class

Insert information into the databas without explicitly writing the query.Does not use a prepared statement.

insertStatement( $table_name,  $data,  $options = array()) : void
static
access

public

Arguments

$table_name

$data

$options

Sanitizes information before it is inserted into the database. Should be used on all user input to ensure security. Can sanitize a single string or an array of data.

makeSafe(mixed $string) : mixed
static

Example:: $name=PVDatabase::makeSafe($_POST['name']); $number=PVDatabase::makeSafe($_POST['number']); PVDatabase::query("INSERT INTO TABLE(name, number) VALES('$name', '$number');

access

public

Arguments

$string

mixed

String can either be a string or an array of data

Response

mixed

$sanitized_data If the input is a string, a string will be return if the input is an array, an array will be returned/

Takes in an array of values that is formated like a query, and parse it to become a SQL query. For example:

parseOperators(string $column, array $args = array(), string $key = 'AND', string $operator = '=', boolean $first = true) : string
static

array('>' = '5') will become column > 5

todo

Rewrite this function and description for clarity

Arguments

$column

string

The name of column to do the comparison operation

$args

array

The args in key value and subkey value. The keys are conditionals and the value are what te conditio is being compparied too

$key

string

They conditional, either AND or OR for the query

$operator

string

How to compare values

$first

boolean

For recursive operation, is this the first value

Response

string

$query A query to execute

Deletes a row in the database spcefied by parameters passed. Use this function with caution.

preparedDelete(string $table, array $wherelist = array(), array $whereformats = array(), array $options = array()) : void
static

Arguments

$table

string

The table the information will be deleted from.

$wherelist

array

An array of whats fields to use when deleting the data. The key of the array should be the column name and the array's key value should be the value present in the column.

$whereformats

array

Formats for the where.

$options

array

Options mainly for MongoDB

Function needs improvment.

preparedInsert(string $table_name, array $data, array $formats = array()) 
static
access

public

todo

write better code

Arguments

$table_name

string

$data

array

$formats

array

Executes a prepared Query that will be inserted into the database. Function still needs work before being used.

preparedQuery(string $query, array $data, string $formats = '') 
static
todo

fix

Arguments

$query

string

$data

array

$formats

string

Inserts a query into the database and returns the id of the field that was last inserted.

preparedReturnLastInsert( $table_name,  $returnField,  $returnTable, array $data, array $formats = array(), array $options = array()) 
static

The query will be a prepared statement.

access

public

todo

write better code

Arguments

$table_name

$returnField

$returnTable

$data

array

The data to be inserted in the format of the key being the column and the key's value being the data.

$formats

array

Still in progress. Formats a preparted statemet.

$options

array

Options mainly used for Mongo

Executes a prepared select statement. Complex statements are complex enough that the data must be formated outside. The passed query should already have the ? inserted for values. The data array passed should correspond to that values.Futures version will have a select statement that handles the data in a better way.

preparedSelect(string $query, array $data, array $formats = array(), array $options = array()) : \data
static
access

public

todo

write better code

Arguments

$query

string

A query of formatted data to be inserted into the database.

$data

array

Data to be inserted into the database. The key should be the column name and the value should be the column's value.

$formats

array

The formats for a prepared statement

$options

array

Options than can be used to alter the query and its function -prequery string: SQL to add before the query -postquery string: Additonal information to add at the end of the normal

Response

\data

result: Retuns a result that will need to be run through fetch process.

Updates a tables data using a prepared query.

preparedUpdate(string $table, array $data, array $wherelist, array $formats = array(), array $whereformats = array(), array $options = array()) 
static
access

public

todo

write better code

Arguments

$table

string

The name of the table to be updated.

$data

array

$wherelist

array

$formats

array

$whereformats

array

$options

array

Executes a SQL Query.passed to the function. The query passed should be sanitized for malicous code before being processed.

query(string $query) : object
static

Example: $query='Select * FROM TABLE'; $result=PVDatabase::query($query);

access

public

Arguments

$query

string

A SQL query

Response

object

$result Returns an object result related to the query passed

Removes an adapter.

removeAdapter( $class, string $method) : void
inherited static
access

public

Arguments

$class

$method

string

The associated method

Removes an adapter for an entire class.

removeClassAdapter( $class) : void
inherited static
access

public

Arguments

$class

Get the number of rows return in a SELECT sql statement. Function with automatically decide which database to use.

resultRowCount(object $result) : integer
static

Example: $result=PVDatabase::query("SELECT * FROM TABLE"); $count=PVDatabase::resultRowCount($result);

access

public

Arguments

$result

object

A result from a query

Response

integer

$count The number of rows in that result.

Returns the id of the last inserted string into the databse.

return_last_insert_query(string $query, string $returnField = '', string $returnTable = '') : mixed
static

returnField and returnTable are generally optional but required for databases such as PostgreSQL and MSSSQL

Example: $query="INSERT INTO TABLE('Test Data') VALUES('abc', '123')"; $id=PVDatabase::return_last_insert_query($query, 'id', 'TABLE');

access

public

Arguments

$query

string

The query thing to be executed

$returnField

string

The field that is auto incremented and will be returned

$returnTable

string

The table the auto-incremented value exist in

Response

mixed

$id The id of the last inserted field

A SELECT query that will run as a prepared statement

selectPreparedStatement(array $args, array $options = array()) 
static

Arguments

$args

array

$options

array

Creates a select statement to query data in the database.

selectStatement(array $args, array $options = array()) : \$mixed
static
access

public

Arguments

$args

array

An array of arguement that define the select statement

$options

array

Options to alter the select statement

Response

\$mixed

$results

Adds a value to the classes Collection. By default the collection is stored in the public collection. The stored instance can be retrieved later by called in it's key value.

set(string $index, mixed $value) : void
inherited static
access

public

Arguments

$index

string

The key or index to store the value at

$value

mixed

A mixed value that can be anytype

Turn on/off the ability to trace an adapter.Turning on will log an adapter using PVLog when adapter is executed.

setAdapterTrace(boolean $trace = false) : void
inherited static
access

public

Arguments

$trace

boolean

Default is false. If set to true, will trace adatper.

Set the database to one in the configuration file or to one passed used the PVDatabase::addConnection method(). Will close the other database link if open and create a new one.

setDatabase( $profile_id) : void
static

Example: PVDatabase::setDatabase(0);

access

public

Arguments

$profile_id

Turn on/off the ability to trace an filter.Turning on will log a filter using PVLog when filter is executed.

setFilterTrace(boolean $trace = false) : void
inherited static
access

public

Arguments

$trace

boolean

Default is false. If set to true, will trace filter.

Turn on/off the ability to trace an observer.Turning on will log an observer using PVLog when the observer is executed.

setObserverTrace(boolean $trace = false) : void
inherited static
access

public

Arguments

$trace

boolean

Default is false. If set to true, will trace observer.

For prepared statements, binds an associatve array. Used for myql.

stmt_bind_assoc(string &$stmt, string &$out) 

Arguments

$stmt

string

The mysql statement

$out

string

The output

Checks to see of a certain table exist within a database.

tableExist(string $tablename, string $schema = '') : boolean
static

Example: if(!PVDatabase::tableExist('contacts')){ //Create table code }

access

public

Arguments

$tablename

string

The name of the table being checked if it exist

$schema

string

Add a schema to check against

Response

boolean

$exist Will be true if the tabe exist, else false;

Update record(s) in the database depending on the arguements specified in the wherelist

updateStatement(string $table, array $data, array $wherelist, array $options = array()) : void
static
access

public

Arguments

$table

string

The name of the table to update

$data

array

The data to update in key => value ( column => value ) format

$wherelist

array

Options defined on where to update the value

$options

array

Extra options when updating a table

Properties

The current query being executed

theQuery : 
static

Type(s)

Not sure what this was for

version : 
static

Type(s)

MYSQL Connection indicator

mySQLConnection : 
static

Type(s)

Postgresql Connection Indicator

postgreSQLConnection : 
static

Type(s)

Oracle connection indicator

oracleConnection : 
static

Type(s)

MSSQL connection indicator

msSQLConnection : 
static

Type(s)

SQL Light connection indicatir

sqLiteConnection : 
static

Type(s)

MongoDB connection dicator

mongoConnection : 
static

Type(s)

An array of possible connections that have been added

connections : 
static

Type(s)

Ability to execute myself connections

mysql_error_report : 
static

Type(s)

The host of the current datbase

dbhost : 
static

Type(s)

The name of the current database

dbname : 
static

Type(s)

The user to login to the current datbase

dbuser : 
static

Type(s)

The password to access the current database

dbpass : 
static

Type(s)

The type of DB being accessed(Postgresql, Mysql, ETC)

dbtype : 
static

Type(s)

A schema to be accessed, if any

dbschema : 
static

Type(s)

Optional prefixes for the tables

dbprefix : 
static

Type(s)

The port for the current database

dbport : 
static

Type(s)

The current database connection being referenced

current_connecton : 
static

Type(s)

A row of data

row : 
static

Type(s)

A collection of items that belong to this class

_collection : 
inherited static

Type(s)

A collection of dynamically added methods that below to this class

_methods : 
inherited static

Type(s)

The adapters that have been added

_adapters : 
inherited static

Type(s)

Observers that have been added

_observers : 
inherited static

Type(s)

Instances for singleton that have added

_instances : 
inherited static

Type(s)

Intercepting filters that have been added

_filters : 
inherited static

Type(s)

Boolean for following and logging adapters that have been added

_traceAdapters : 
inherited static

Type(s)

Boolean for following and logging filters that have been added

_traceFilters : 
inherited static

Type(s)

Boolean for following and logging observers that have been added.

_traceObservers : 
inherited static

Type(s)