HRDIODB
[ class tree: HRDIODB ] [ index: HRDIODB ] [ all elements ]

Class: mcpear

Source Location: /mcpear_class.php

Class Overview


A PEAR DB based class for interacting with a SQL database.


Methods


Child classes:

hrdi_db
HRDI database class.

Class Details

[line 36]
A PEAR DB based class for interacting with a SQL database.

Generic PEAR DB function wrappers used for various DB operations. PEAR is a very handy and easy to use library, but having some wrappers makes using it even easier and faster. This also allows for central error checking and handy utility functions. For more information about PEAR, please see http://pear.php.net.




[ Top ]


Class Methods


constructor mcpear [line 42]

mcpear mcpear( [string $dsn = FALSE])

Constructor.

Establishes database connection.




Parameters:

string   $dsn   Data Source Name

[ Top ]

method add [line 202]

mixed add( array $values, string $table)

Adds a table row.

Adds a tabe row to the specific $table using the keys of the $values array as field names and the values as values for those fields.




Tags:

return:  Query result resource or FALSE on error


Overridden in child classes as:

hrdi_db::add()
HRDI specific add function.

Parameters:

array   $values   Associative array of keys and values
string   $table   Table name

[ Top ]

method db_connect [line 59]

mixed db_connect( )

Initializes a PEAR database connection.

Textbook PEAR database connection function.




Tags:

return:  PEAR DB Database connection


[ Top ]

method db_query [line 84]

mixed db_query( string $sql)

General database query method.

Textbook PEAR database query. We use getuserinfo() for error information.




Tags:

return:  Query result resource or FALSE on error


Parameters:

string   $sql   SQL query

[ Top ]

method delete [line 256]

mixed delete( array $values, string $table, string $where_key)

Deletes table rows.

Deletes table rows from a specific $table using the value of the $values array's $where_key key as field name and value as value for the WHERE clause.




Tags:

return:  Query result resource or FALSE on error


Parameters:

array   $values   Associative array of keys and values
string   $table   Table name
string   $where_key   A key into the $values array used for the WHERE clause

[ Top ]

method get_column [line 118]

mixed get_column( string $sql)

Retrieves a column of data.

Retrieves a column of data composed of the first row of the results for the given SQL query.




Tags:

return:  Column of results or FALSE on error


Parameters:

string   $sql   SQL query

[ Top ]

method get_field_names [line 140]

mixed get_field_names( string $table)

Retrieves an array of field names.

Retrieves an array of field names in a given table.




Tags:

return:  An array of field names for a given table or FALSE on error


Parameters:

string   $table   SQL query

[ Top ]

method get_list [line 106]

mixed get_list( string $sql)

Retrieves a list of data.

Returns a list of data for the given SQL query.




Tags:

return:  List of results or FALSE on error


Parameters:

string   $sql   SQL query

[ Top ]

method get_one [line 129]

mixed get_one( string $sql)

Retrieves a single value.

Retrieves the value of the first result for the given SQL query.




Tags:

return:  Value of the first result or FALSE on error


Parameters:

string   $sql   SQL query

[ Top ]

method get_row [line 95]

mixed get_row( string $sql)

Retrieves a row of data.

Returns a row of data for the given SQL query.




Tags:

return:  Row of data or FALSE on error


Parameters:

string   $sql   SQL query

[ Top ]

method get_table [line 172]

mixed get_table( string $table)

Returns table contents.

Returns an array of associative arrays for the given SQL query.




Tags:

return:  Associative array of results or FALSE on error


Parameters:

string   $table   Table name

[ Top ]

method get_total [line 158]

mixed get_total( string $table)

Returns table row count.

Returns the total number of rows in a given table.




Tags:

return:  Number of rows in the table or FALSE on error


Parameters:

string   $table   Table name

[ Top ]

method next_id [line 189]

integer next_id( string $name)

Returns next insert id.

Returns the next insert id for the sequence $name. Depending on the database you're using, native sequences may or may not exist. PEAR tries to handle things equally by using native sequences in databases which support them, or creating sequence tables in those who don't. By default, PEAR will add the string "_seq" to any sequence name. Keep that in mind when asking it for the next sequence number.




Tags:

return:  Next id sequence number


Parameters:

string   $name   The name of the sequence

[ Top ]

method update [line 229]

mixed update( array $values, string $table, string $where_key)

Updates table rows.

Updates table rows for the specific $table using the keys of the $values array as field names and the values as values for those fields.




Tags:

return:  Query result resource or FALSE on error


Overridden in child classes as:

hrdi_db::update()
HRDI specific update function.

Parameters:

array   $values   Associative array of keys and values
string   $table   Table name
string   $where_key   A key into the $values array used for the WHERE clause

[ Top ]

method verify [line 271]

mixed &verify( &$result, mixed $result)

Returns the result or prints an error.

This function is meant to be used in the 'return' statement of all mcpear functions. It checks to see if there is a valid result or a DB error. If the result is valid, it is returned. If there is a DB error, it is printed and FALSE is returned.




Tags:

return:  Query result or FALSE on error


Parameters:

mixed   $result   DB result
   &$result  

[ Top ]


Documentation generated on Tue, 23 Jan 2007 22:57:49 -0500 by phpDocumentor 1.3.0RC6