TITAN Library for PHP5  5.1.0
Web Software Development Kit for PHP5
pdo Class Reference

Titan PDO Base Class. More...

Inheritance diagram for pdo:
callback mssql mysql

Public Member Functions

 __construct ($type, $host, $user, $pass, $database= '')
 
 connect ($user= '', $pass= '')
 
 close ()
 
 select ($database= '')
 
 get_error ()
 
get_field_names ($table)
 
get_field_defs ($table, $name_only=true)
 
 field_exists ($table, $field)
 
 table_exists ($table)
 
 database_exists ($database)
 
 show_databases ($database= '', $exclude_system=true)
 
 show_tables ($database, $table= '')
 
 unquery ($query)
 
 free_result ()
 
 count ($table, $where= '1')
 
get_row ($query)
 
get_rows ($query)
 
get_rows_cb ($callback, $query)
 
 slash ($text= '')
 
 delete ($table, $where)
 
 insert ($obj, $table, $auto_increment= 'idx')
 
 update ($obj, $table, $where= '', $existing_obj=false)
 
- Public Member Functions inherited from callback
 __construct ($callback=NULL)
 
 callback ($callback=NULL)
 
 argument ($value)
 
 parameter ($name, $value= '')
 
factory (array $arguments=array())
 
execute ()
 

Data Fields

 $database = ''
 Database server selected database.
 
 $connected = false
 Is a database server connected?
 
 $db_ready = false
 Is a database selected?
 
 $last_query = false
 Last query performed.
 
 $result = false
 PDOStatement object of last executed query.
 
 $error = ''
 Error message, if any.
 

Protected Attributes

 $pdo = false
 PDO object, link to database.
 
 $options = array()
 PDO connection options.
 
 $dsn = ''
 Database dsn.
 
 $type = ''
 Database driver type ('mysql or mssql (auto changes to sqlsrv))
 
 $host = ''
 Database server hostname (and port if needed)
 
 $port = 0
 Database server port (exploded from $host)
 
 $user = null
 Database server username.
 
 $pass = null
 Database server password.
 
 $backticks = false
 Wrap table and field names in backticks?
 

Additional Inherited Members

- Protected Member Functions inherited from callback
arguments (array $arguments=array())
 

Detailed Description

Titan PDO Base Class.

Class: \tl\io\pdo\pdo

Author
James E. Bush work@.nosp@m.bush.nosp@m..cc
Version
5.1.0

Constructor & Destructor Documentation

__construct (   $type,
  $host,
  $user,
  $pass,
  $database = '' 
)

pdo object constructor

Parameters
string$typeone of ('mysql' or 'mssql')
string$hostdatabase server hostname[:port]
string$userdatabase server credentials: username
string$passdatabase server credentials: password
string$database(optional) database server selected default database (default) '' = do not select a database
Returns
object Database connector object

Member Function Documentation

connect (   $user = '',
  $pass = '' 
)

Connect to the database server.

Parameters
string$userdatabase server credentials: username
string$passdatabase server credentials: password
close ( )

Close the connection to the database server and reset this object's internal properties.

select (   $database = '')

Select a default database on the database server.

Parameters
string$databasedatabase server selected default database
Returns
bool success or failure
get_error ( )

Check for an error

Returns
string database error
& get_field_names (   $table)

Get all field names in a table

Parameters
string$tabletable name to check
Returns
array array of field names
& get_field_defs (   $table,
  $name_only = true 
)

Get all field definitions in a table

Parameters
string$tabletable name to check
bool$name_onlyresult set: true = names only, false = full field definitions
Returns
array array of field names or definitions
field_exists (   $table,
  $field 
)

Does the field exist in a given table in the currently selected database? You MUST have a database selected first. This will return FALSE if the field does exist but the current sql user does not have access to it.

Parameters
string$tableThe name of the table to check
string$fieldThe name of the field to check
Returns
boolean
table_exists (   $table)

Does the table exist in the currently selected database? You MUST have a database selected first. This will return FALSE if the table does exist but the current sql user does not have access to it.

Parameters
string$tableThe name of the table to check
Returns
boolean
database_exists (   $database)

Does the database exist? This will return FALSE if the database does exist but the current sql user does not have access to it.

Parameters
string$databaseThe name of the database to check
Returns
boolean
show_databases (   $database = '',
  $exclude_system = true 
)

Return a list of databases. This will only list databases the curent sql user has access to.

Parameters
string$database(optional) If a database name is set, checks if it exists (default) '' = Return a list of databases
boolean$exclude_system(optional) Exclude MySQL system tables (default) true
Returns
mixed FALSE or string $database or array of databases
show_tables (   $database,
  $table = '' 
)

Return a list of tables in a database. This will only list tables the curent sql user has access to, and only if the sql user has access to the database.

Parameters
string$databaseThe database to list tables
string$table(optional) If a table name is set, checks if it exists (default) '' = Return a list of tables
Returns
mixed FALSE or string $table or array of tables
unquery (   $query)

Execute an query that does not return anything (e.g. insert, update, call). If you call this with a select query, you will not get a result set.

Parameters
string$queryThe SQL query to execute
free_result ( )

Free the result set from the database server's memory

count (   $table,
  $where = '1' 
)

Count the number of records in $table matching $where

Parameters
string$tableThe table to check
string$whereSQL "where" clause (WITHOUT the word "where")
Returns
int The number of matching rows
& get_row (   $query)

Get a single row from the database

Parameters
string$queryThe SQL query to execute
Returns
mixed (by reference) The resulting row
& get_rows (   $query)

Get an array of rows from the database

Parameters
string$queryThe SQL query to execute
Returns
array (by reference) An array of the resulting rows
& get_rows_cb (   $callback,
  $query 
)

Get a set of rows from the database. Applies a callback function to each row before adding it to the result array. The callback funcion should accept the object (or array) as its first parameter by reference! Then, if the callback sets the object to boolean false, the result is not added to the result array.

Parameters
string$callbackThe callback function or array(class, method) to use for each result
string$queryThe SQL query to execute
Returns
array (by reference) An array of the resulting rows
slash (   $text = '')

Determine the data type and add slashes as needed.

Parameters
string$textThe string to escape
Returns
string The escaped string
delete (   $table,
  $where 
)

Delete record(s)

Parameters
string$tableName of the table to insert into.
string$whereSelect statement "where" clause
insert (   $obj,
  $table,
  $auto_increment = 'idx' 
)

Insert a single record, (optional) skip the auto_increment field if one exists

Parameters
object$objObject whose properties will be used to fill the table's fields.
string$tableName of the table to insert into.
boolean$auto_increment(optional) Name of the table's auto-increment field (default) 'idx'
Returns
bool Success?
update (   $obj,
  $table,
  $where = '',
  $existing_obj = false 
)

Update a single record with up to three simple key/val indexes.

Parameters
object$objObject whose properties will be used to fill the table's fields
string$tableName of the table to insert into
string$whereSelect statement "where" clause
object$existing_objUse this object instead of selecting from the database (ignore, leave false)
Returns
bool Success?

The documentation for this class was generated from the following file: