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

Procedural File: lib-database.php

Source Location: /system/lib-database.php



Page Details:

This is the high-level database layer for Geeklog (for the low-level stuff, see the system/databases directory).

NOTE: As of Geeklog 1.3.5 you should not have to edit this file any more.




Includes:

require_once($_CONF['path_system'].'databases/'.$_DB_dbms.'.class.php') [line 132]
Include appropriate DBMS object







DBINT_parseCsvSqlString [line 596]

array DBINT_parseCsvSqlString( string $csv)

Parse a CSV-like SQL string, as used by DB_save

This function will help parse the CVS-like strings that are used by DB_save. Those are specific to MySQL and have to be handled separately by other DBs.

Since nothing can do this properly, I had to write it myself. Trick is that a string csv may have a comma within a delimited csv field which explode can't handle.




Tags:

return:  parsed string contents
author:  Randy Kolenko
see:  DB_save()


Parameters

string   $csv   The string to parse
[ Top ]



DB_affectedRows [line 426]

int DB_affectedRows( object $recordset)

Retrieves returns the number of effected rows for last query

Retrieves returns the number of effected rows for last query




Tags:

return:  returns numbe of rows affected by previously executed query


Parameters

object   $recordset   The recordset to operate on
[ Top ]



DB_change [line 294]

void DB_change( string $table, string $item_to_set, string $value_to_set, [array|string $id = ''], [array|string $value = ''], [string $return_page = ''], [boolean $supress_quotes = false])

Changes records in a table

This will change the data in the given table that meet the given criteria and will redirect user to another page if told to do so




Parameters

string   $table   Table to perform change on
string   $item_to_set   field name to set
string   $value_to_set   Value to set abovle field to
array|string   $id   field name(s) to use in where clause
array|string   $value   Value(s) to use in where clause
string   $return_page   page to send user to when done with change
boolean   $supress_quotes   whether or not to use single quotes in where clause
[ Top ]



DB_checkTableExists [line 551]

boolean DB_checkTableExists( string $table)

Check if a table exists



Tags:

return:  True if table exists, false if it does not


Parameters

string   $table   Table name
[ Top ]



DB_copy [line 339]

void DB_copy( string $table, string $fields, string $values, string $tablefrom, array|string $id, array|string $value, [string $return_page = ''])

Copies a record from one table to another (can be the same table)

This will use a REPLACE INTO...SELECT FROM to copy a record from one table to another table. They can be the same table.




Parameters

string   $table   Table to insert record into
string   $fields   Comma delmited list of fields to copy over
string   $values   Values to store in database field
string   $tablefrom   Table to get record from
array|string   $id   Field name(s) to use in where clause
array|string   $value   Value(s) to use in where clause
string   $return_page   Page to send user to when done
[ Top ]



DB_count [line 317]

int DB_count( string $table, [array|string $id = ''], [array|string $value = ''])

Count records in a table

This will return the number of records which meet the given criteria in the given table.




Tags:

return:  Returns row count from generated SQL


Parameters

string   $table   Table to perform count on
array|string   $id   field name(s) to use in where clause
array|string   $value   Value(s) to use in where clause
[ Top ]



DB_createDatabaseStructures [line 489]

boolean DB_createDatabaseStructures( )

Creates database structures for fresh installation

This may not be used by Geeklog currently




Tags:

return:  returns true on success otherwise false


[ Top ]



DB_delete [line 247]

void DB_delete( string $table, array|string $id, array|string $value, [string $return_page = ''])

Deletes data from the database

This will delete some data from the given table where id = value




Parameters

string   $table   Table to delete data from
array|string   $id   field name(s) to use in where clause
array|string   $value   value(s) to use in where clause
string   $return_page   page to send user to when done
[ Top ]



DB_displayError [line 174]

void DB_displayError( boolean $flag)

Setting this on will return the SQL error message.

Default is to not display or return the SQL error but to record it in the error.log file




Parameters

boolean   $flag   true or false
[ Top ]



DB_doDatabaseUpgrade [line 503]

boolean DB_doDatabaseUpgrade( string $current_gl_version)

Executes the sql upgrade script(s)



Tags:

return:  returns true on success otherwise false


Parameters

string   $current_gl_version   version of geeklog to upgrade from
[ Top ]



DB_error [line 474]

string DB_error( )

returns a database error string

Returns an database error message




Tags:

return:  Returns database error message


[ Top ]



DB_fetchArray [line 443]

Array DB_fetchArray( object $recordset, [boolean $both = true])

Retrieves record from a recordset

Gets the next record in a recordset and returns in array




Tags:

return:  Returns data for a record in an array


Parameters

object   $recordset   The recordset to operate on
boolean   $both   get both assoc and numeric indices
[ Top ]



DB_fieldName [line 410]

string DB_fieldName( object $recordset, int $fnumber)

Retrieves returns the field name for a field

Returns the field name for a given field number




Tags:

return:  Returns name of specified field


Parameters

object   $recordset   The recordset to operate on
int   $fnumber   field number to return the name of
[ Top ]



DB_getItem [line 268]

mixed DB_getItem( string $table, string $what, [string $selection = ''])

Gets a single item from the database



Tags:

return:  Returns value sought


Parameters

string   $table   Table to get item from
string   $what   field name to get
string   $selection   Where clause to use in SQL
[ Top ]



DB_getVersion [line 653]

string DB_getVersion( )



Tags:

return:  the version of the database server


[ Top ]



DB_insertId [line 459]

int DB_insertId( [resources $link_identifier = ''], [ $sequence = ''])

Returns the last ID inserted

Returns the last auto_increment ID generated




Tags:

return:  Returns the last ID auto-generated


Parameters

resources   $link_identifier   identifier for opened link
   $sequence  
[ Top ]



DB_lockTable [line 520]

void DB_lockTable( string $table)

Lock a table

Locks a table for write operations




Tags:



Parameters

string   $table   Table to lock
[ Top ]



DB_numFields [line 393]

int DB_numFields( object $recordset)

Retrieves the number of fields in a recordset

This returns the number of fields in a recordset




Tags:

return:  Returns the number fields in a result set


Parameters

object   $recordset   The recordset to operate on
[ Top ]



DB_numRows [line 359]

int DB_numRows( object $recordset)

Retrieves the number of rows in a recordset

This returns the number of rows in a recordset




Tags:

return:  Returns number of rows returned by a previously executed query


Parameters

object   $recordset   The recordset to operate one
[ Top ]



DB_query [line 191]

object Returns DB_query( mixed $sql, [int $ignore_errors = 0])

Executes a query on the db server

This executes the passed SQL and returns the recordset or errors out




Tags:

return:  results from query


Parameters

mixed   $sql   String or array of strings of SQL to be executed
int   $ignore_errors   If 1 this function supresses any error messages
[ Top ]



DB_result [line 377]

(depends DB_result( object $recordset, int $row, string $field)

Retrieves the contents of a field

This returns the contents of a field from a result set




Tags:

return:  on the contents of the field)


Parameters

object   $recordset   The recordset to operate on
int   $row   row to get data from
string   $field   field to return
[ Top ]



DB_save [line 224]

void DB_save( string $table, string $fields, string $values, [string $return_page = ''])

Saves information to the database

This will use a REPLACE INTO to save a record into the database. NOTE: this function is going to change in the near future to remove dependency of REPLACE INTO. Please use DB_query if you can




Parameters

string   $table   The table to save to
string   $fields   Comma demlimited list of fields to save
string   $values   Values to save to the database table
string   $return_page   URL to send user to when done
[ Top ]



DB_setDebug [line 161]

void DB_setDebug( boolean $flag)

Turns debug mode on for the database library

Setting this to true will cause the database code to print out various debug messages. Setting it to false will supress the messages (is false by default). NOTE: Gl developers have put many useful debug messages into the mysql implementation of this. If you are using something other than MySQL and if the GL team did not write it then you may or may not get something useful by turning this on.




Parameters

boolean   $flag   true or false
[ Top ]



DB_unlockTable [line 537]

void DB_unlockTable( string $table)

Unlock a table

Unlocks a table after DB_lockTable




Tags:

see:  DB_lockTable()


Parameters

string   $table   Table to unlock
[ Top ]



Documentation generated on Sat, 11 Feb 2012 02:08:18 -0500 by phpDocumentor 1.4.3