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

Class: KDatabaseAdapterInterface

Source Location: /libraries/koowa/database/adapter/interface.php

Interface Overview


Database Adapter Interface


Author(s):

Methods



Class Details

[line 18]
Database Adapter Interface



Tags:

author:  Johan Janssens <johan@nooku.org>


[ Top ]


Class Methods


method connect [line 32]

KDatabaseAdapterAbstract connect( )

Connect to the db



Tags:

access:  public


[ Top ]

method delete [line 161]

integer delete( string $table, mixed $where)

Deletes rows from the table based on a WHERE clause.



Tags:

return:  Number of rows affected
access:  public


Parameters:

string   $table   The table to update
mixed   $where   A query string or a KDatabaseQuery object to limit which rows are updated.

[ Top ]

method disconnect [line 46]

KDatabaseAdapterAbstract disconnect( )

Disconnect from db



Tags:

access:  public


[ Top ]

method execute [line 175]

boolean execute( string $sql, [integer $mode = KDatabase::RESULT_STORE])

Use and other queries that don't return rows



Tags:

return:  For SELECT, SHOW, DESCRIBE or EXPLAIN will return a result object. For other successful queries return TRUE.
throws:  KDatabaseException
access:  public


Parameters:

string   $sql   The query to run. Data inside the query should be properly escaped.
integer   $mode   The result maode, either the constant KDatabase::RESULT_USE or KDatabase::RESULT_STORE depending on the desired behavior. By default, KDatabase::RESULT_STORE is used. If you use KDatabase::RESULT_USE all subsequent calls will return error Commands out of sync unless you free the result first.

[ Top ]

method getConnection [line 56]

resource getConnection( )

Get the connection

Provides access to the underlying database connection. Useful for when you need to call a proprietary method such as postgresql's lo_* methods




Tags:

access:  public


[ Top ]

method getInsertId [line 78]

mixed getInsertId( )

Get the insert id of the last insert operation



Tags:

return:  The id of the last inserted row(s)
access:  public


[ Top ]

method getQuery [line 25]

KDatabaseQuery getQuery( [ $config = null])

Get a database query object



Tags:

access:  public


Parameters:

KConfig   $config  

[ Top ]

method getTableNeedle [line 200]

string getTableNeedle( )

Get the table needle



Tags:

return:  The table needle
see:  KDatabaseAdapterAbstract::replaceTableNeedle
access:  public


[ Top ]

method getTablePrefix [line 192]

string getTablePrefix( )

Get the table prefix



Tags:

return:  The table prefix
see:  KDatabaseAdapterAbstract::replaceTableNeedle
access:  public


[ Top ]

method getTableSchema [line 86]

KDatabaseSchemaTable getTableSchema( string $table)

Retrieves the column schema information about the given table



Tags:

access:  public


Parameters:

string   $table   A table name

[ Top ]

method insert [line 139]

integer insert( string $table, $data)

Inserts a row of data into a table.

Automatically quotes the data values




Tags:

return:  If successfull the new rows primary key value, false is no row was inserted.
access:  public


Parameters:

string   $table   The table to insert data into.
array   $data   An associative array where the key is the colum name and the value is the value to insert for that column.

[ Top ]

method isConnected [line 71]

boolean isConnected( )

Determines if the connection to the server is active.



Tags:

access:  public


[ Top ]

method lockTable [line 95]

boolean lockTable( string $base, string $name)

Lock a table.



Tags:

return:  True on success, false otherwise.
access:  public


Parameters:

string   $base   Base name of the table.
string   $name   Real name of the table.

[ Top ]

method quoteName [line 234]

string|array quoteName( string|array $spec)

Quotes a single identifier name (table, table alias, table column, index, sequence). Ignores empty values.

This function requires all SQL statements, operators and functions to be uppercased.




Tags:

return:  The quoted identifier name (or array of names).
access:  public


Parameters:

string|array   $spec   The identifier name to quote. If an array, quotes each element in the array as an identifier name.

[ Top ]

method quoteValue [line 221]

string quoteValue( mixed $value)

Safely quotes a value for an SQL statement.

If an array is passed as the value, the array values are quoted and then returned as a comma-separated string; this is useful for generating IN() lists.




Tags:

return:  An SQL-safe quoted value (or a string of separated- and-quoted values).
access:  public


Parameters:

mixed   $value   The value to quote.

[ Top ]

method reconnect [line 39]

KDatabaseAdapterAbstract reconnect( )

Reconnect to the db



Tags:

access:  public


[ Top ]

method replaceTableNeedle [line 208]

string replaceTableNeedle( string $sql)

This function replaces the table needles in a query string with the actual table prefix.



Tags:

return:  The SQL query string
access:  public


Parameters:

string   $sql   The SQL query string

[ Top ]

method select [line 116]

mixed select( string $sql, [integer $mode = KDatabase::RESULT_STORE])

Preforms a select query

Use for SELECT and anything that returns rows.




Tags:

return:  If successfull returns a result object otherwise FALSE
access:  public


Parameters:

string   $sql   A full SQL query to run. Data inside the query should be properly escaped.
integer   $mode   The result maode, either the constant KDatabase::RESULT_USE or KDatabase::RESULT_STORE depending on the desired behavior. By default, KDatabase::RESULT_STORE is used. If you use KDatabase::RESULT_USE all subsequent calls will return error Commands out of sync unless you free the result first.

[ Top ]

method setConnection [line 64]

KDatabaseAdapterAbstract setConnection( resource $resource)

Set the connection



Tags:

access:  public


Parameters:

resource   $resource   The connection resource

[ Top ]

method setTablePrefix [line 184]

KDatabaseAdapterAbstract setTablePrefix( string $prefix)

Set the table prefix



Tags:

see:  KDatabaseAdapterAbstract::replaceTableNeedle
access:  public


Parameters:

string   $prefix   The table prefix

[ Top ]

method show [line 127]

mixed show( string|object $query, [integer $mode = KDatabase::FETCH_ARRAY_LIST])

Preforms a show query



Tags:

return:  The return value of this function on success depends on the fetch type. In all cases, FALSE is returned on failure.
access:  public


Parameters:

string|object   $query   A full SQL query to run. Data inside the query should be properly escaped.
integer   $mode   The fetch mode. Controls how the result will be returned to the caller. This value must be one of the KDatabase::FETCH_* constants.

[ Top ]

method unlockTable [line 102]

boolean unlockTable( )

Unlock a table.



Tags:

return:  True on success, false otherwise.
access:  public


[ Top ]

method update [line 152]

integer update( string $table, $data, [mixed $where = null])

Updates a table with specified data based on a WHERE clause

Automatically quotes the data values




Tags:

return:  If successfull the Number of rows affected, otherwise false
access:  public


Parameters:

string   $table   The table to update
array   $data   An associative array where the key is the column name and the value is the value to use ofr that column.
mixed   $where   A sql string or KDatabaseQuery object to limit which rows are updated.

[ Top ]


Documentation generated on Sat, 18 May 2013 03:04:39 +0200 by phpDocumentor 1.4.3