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/mysqli.class.php') [line 131]
Include appropriate DBMS object

require_once($_CONF['path_system'].'databases/'.$_DB_dbms.'.class.php') [line 133]






DBINT_parseCsvSqlString [line 532]

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 402]

int DB_affectedRows( mixed $recordSet)

Retrieves returns the number of effected rows for last query Retrieves returns the number of effected rows for last query



Tags:

return:  returns number of rows affected by previously executed query


Parameters

mixed   $recordSet   The record set to operate on
[ Top ]



DB_change [line 284]

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 511]

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 325]

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 305]

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 457]

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 240]

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 470]

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 444]

string DB_error( )

returns a database error string Returns an database error message



Tags:

return:  Returns database error message


[ Top ]



DB_escapeString [line 603]

string DB_escapeString( string $str)

Escapes a string so that it can be safely used in a query



Parameters

string   $str   a string to be escaped
[ Top ]



DB_fetchArray [line 417]

array DB_fetchArray( mixed $recordSet, [boolean $both = true])

Retrieves record from a record set Gets the next record in a record set and returns in array



Tags:

return:  Returns data for a record in an array


Parameters

mixed   $recordSet   The record set to operate on
boolean   $both   get both assoc and numeric indices
[ Top ]



DB_fieldName [line 388]

string DB_fieldName( mixed $recordSet, int $fieldNumber)

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

mixed   $recordSet   The recordset to operate on
int   $fieldNumber   field number to return the name of
[ Top ]



DB_getItem [line 259]

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 590]

string DB_getVersion( )



Tags:

return:  the version of the database server


[ Top ]



DB_insertId [line 431]

mixed DB_insertId( [resource $link_identifier = ''], [ $sequence = ''])

Returns the last ID inserted Returns the last auto_increment ID generated



Tags:

return:  Returns the last ID auto-generated


Parameters

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



DB_lockTable [line 484]

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 373]

int DB_numFields( mixed $recordSet)

Retrieves the number of fields in a record set This returns the number of fields in a record set



Tags:

return:  Returns the number fields in a result set


Parameters

mixed   $recordSet   The recordset to operate on
[ Top ]



DB_numRows [line 343]

int DB_numRows( mixed $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

mixed   $recordSet   The recordset to operate one
[ Top ]



DB_query [line 189]

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 359]

mixed DB_result( mixed $recordSet, int $row, string $field)

Retrieves the contents of a field This returns the contents of a field from a result set



Tags:

return:  (depends on the contents of the field)


Parameters

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



DB_save [line 220]

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 498]

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 Sun, 02 Oct 2016 07:51:25 +0000 by phpDocumentor 1.4.3