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

Class: Database

Source Location: /system/databases/mysql.class.php

Class Overview


This file is the mysql implementation of the Geeklog abstraction layer.


Methods



Class Details

[line 38]
This file is the mysql implementation of the Geeklog abstraction layer.

Unfortunately the Geeklog abstraction layer isn't 100% abstract because a few key functions use MySQL's REPLACE INTO syntax which is not a SQL standard. This issue will need to be resolved some time ...




[ Top ]


Class Methods


constructor __construct [line 218]

Database __construct( string $dbhost, string $dbname, string $dbuser, string $dbpass, string $tablePrefix, [string $errorlogfn = ''], [string $charset = ''])

constructor for database This initializes an instance of the database object



Tags:

access:  public


Parameters:

string   $dbhost   Database host
string   $dbname   Name of database
string   $dbuser   User to make connection as
string   $dbpass   Password for dbuser
string   $tablePrefix   Table prefix
string   $errorlogfn   Name of the errorlog function
string   $charset   Character set to use

[ Top ]

method dbAffectedRows [line 709]

int dbAffectedRows( resource $recordSet)

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



Tags:

return:  Number of rows affected by last query
access:  public


Parameters:

resource   $recordSet   The recordset to operate on

[ Top ]

method dbChange [line 457]

bool dbChange( string $table, string $item_to_set, string $value_to_set, array|string $id, array|string $value, [bool $suppress_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



Tags:

return:  Returns true on success otherwise false
access:  public


Parameters:

string   $table   Table to perform change on
string   $item_to_set   field name of unique ID field for table
string   $value_to_set   Value for id
array|string   $id   additional field name used in where clause
array|string   $value   additional values used in where clause
bool   $suppress_quotes   if false it will not use '<value>' in where clause

[ Top ]

method dbCopy [line 578]

bool dbCopy( string $table, string $fields, string $values, string $tableFrom, array|string $id, array|string $value)

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.



Tags:

return:  Returns true on success otherwise false
access:  public


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 fields
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

[ Top ]

method dbCount [line 517]

bool dbCount( string $table, [array|string $id = ''], [array|string $value = ''])

Returns the number of records for a query that meets the given criteria This will build a SELECT count(*) statement with the given criteria and return the result



Tags:

return:  returns count on success otherwise false
access:  public


Parameters:

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

[ Top ]

method dbDelete [line 399]

bool dbDelete( string $table, array|string $id, array|string $value)

Deletes data from the database This will delete some data from the given table where id = value. If id and value are arrays then it will traverse the arrays setting $id[curval] = $value[curval].



Tags:

return:  Returns true on success otherwise false
access:  public


Parameters:

string   $table   Table to delete data from
array|string   $id   field name(s) to include in where clause
array|string   $value   field value(s) corresponding to field names

[ Top ]

method dbError [line 756]

string dbError( [string $sql = ''])

returns a database error string Returns an database error message



Tags:

return:  Text for error message
access:  public


Parameters:

string   $sql   SQL that may have caused the error

[ Top ]

method dbEscapeString [line 853]

string dbEscapeString( string $str)

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



Tags:

access:  public


Parameters:

string   $str   a string to be escaped

[ Top ]

method dbFetchArray [line 722]

array dbFetchArray( resource $recordSet, [bool $both = false])

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



Tags:

return:  Returns data array of current row from record set
access:  public


Parameters:

resource   $recordSet   The record set to operate on
bool   $both   get both assoc and numeric indices

[ Top ]

method dbFieldName [line 697]

string dbFieldName( resource $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
access:  public


Parameters:

resource   $recordSet   The recordset to operate on
int   $fieldNumber   field number to return the name of

[ Top ]

method dbGetVersion [line 842]

string dbGetVersion( )



Tags:

return:  the version of the database application
access:  public


[ Top ]

method dbInsertId [line 740]

int dbInsertId( [resource $link_identifier = null], [ $sequence = ''])

Returns the last ID inserted Returns the last auto_increment ID generated



Tags:

return:  Returns last auto-generated ID
access:  public


Parameters:

resource   $link_identifier   identifier for opened link
   $sequence  

[ Top ]

method dbLockTable [line 801]

void dbLockTable( string $table)

Lock a table Locks a table for write operations



Tags:

see:  Database::dbUnlockTable()
access:  public


Parameters:

string   $table   Table to lock

[ Top ]

method dbNumFields [line 684]

int dbNumFields( resource $recordSet)

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



Tags:

return:  Returns number of rows from query
access:  public


Parameters:

resource   $recordSet   The record set to operate on

[ Top ]

method dbNumRows [line 628]

int dbNumRows( resource $recordSet)

Retrieves the number of rows in a recordset This returns the number of rows in a recordset



Tags:

return:  Returns number of rows otherwise false (0)
access:  public


Parameters:

resource   $recordSet   The recordset to operate one

[ Top ]

method dbQuery [line 295]

resource|bool dbQuery( string $sql, [int $ignore_errors = 0])

Executes a query on the MySQL server This executes the passed SQL and returns the recordset or errors out



Tags:

return:  Returns results of query
access:  public


Parameters:

string   $sql   SQL to be executed
int   $ignore_errors   If 1 this function supresses any error messages

[ Top ]

method dbResult [line 660]

mixed dbResult( resource $recordSet, int $row, [mixed $field = 0])

Returns the contents of one cell from a MySQL result set



Tags:

return:  (depends on field content)
access:  public


Parameters:

resource   $recordSet   The recordset to operate on
int   $row   row to get data from
mixed   $field   field to return

[ Top ]

method dbSave [line 373]

void dbSave( string $table, string $fields, string $values)

Saves information to the database This will use a REPLACE INTO to save a record into the database



Tags:

access:  public


Parameters:

string   $table   The table to save to
string   $fields   string Comma demlimited list of fields to save
string   $values   Values to save to the database table

[ Top ]

method dbTableExists [line 194]

bool dbTableExists( string $tableName, [int $ignoreErrors = 0])

Return if a given table exists in the current database



Tags:

access:  public


Parameters:

string   $tableName  
int   $ignoreErrors  

[ Top ]

method dbUnlockTable [line 824]

void dbUnlockTable( string $table)

Unlock a table Unlocks a table after a dbLockTable (actually, unlocks all tables)



Tags:

see:  Database::dbLockTable()
access:  public


Parameters:

string   $table   Table to unlock (ignored)

[ Top ]

method isVerbose [line 265]

bool isVerbose( )

Checks to see if debug mode is on Returns value of $_verbose



Tags:

return:  true if in verbose mode otherwise false
access:  public


[ Top ]

method setDisplayError [line 254]

void setDisplayError( bool $flag)

Turns detailed error reporting on If set to true, this will display detailed error messages on the site.

Otherwise, it will only that state an error occurred without going into details. The complete error message (including the offending SQL request) is always available from error.log.




Tags:

access:  public


Parameters:

bool   $flag   true or false

[ Top ]

method setErrorFunction [line 282]

void setErrorFunction( string|callable $functionName)

Sets the function this class should call to log debug messages



Tags:

access:  public


Parameters:

string|callable   $functionName   * $functionName Function name

[ Top ]

method setVerbose [line 240]

void setVerbose( bool $flag)

Turns debug mode on Set this to true to see debug messages



Tags:

access:  public


Parameters:

bool   $flag   true or false

[ Top ]


Documentation generated on Sun, 02 Oct 2016 07:52:35 +0000 by phpDocumentor 1.4.3