CORE POS - IS4C
The CORE POS front end
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
SQLManager Class Reference

Public Member Functions

 __construct ($server, $type, $database, $username, $password='', $persistent=false, $new=false)
 
 add_connection ($server, $type, $database, $username, $password='', $persistent=false)
 
 connect ($server, $type, $username, $password, $persistent=false, $newlink=false)
 
 selectDB ($db_name, $which_connection='')
 
 select_db ($db_name, $which_connection='')
 
 query ($query_text, $which_connection='')
 
 end_query ($result_object, $which_connection='')
 
 insert_id ($which_connection='')
 
 prepare ($query_text, $which_connection='')
 
 prepare_statement ($query_text, $which_connection='')
 
 execute ($stmt, $args=array(), $which_connection='')
 
 exec_statement ($stmt, $args=array(), $which_connection='')
 
 num_rows ($result_object, $which_connection='')
 
 num_fields ($result_object, $which_connection='')
 
 fetch_array ($result_object, $which_connection='')
 
 fetch_row ($result_object, $which_connection='')
 
 fetch_field ($result_object, $index, $which_connection='')
 
 field_type ($result_object, $index, $which_connection='')
 
 close ($which_connection='', $force=false)
 
 db_close ($which_connection='', $force=false)
 
 start_transaction ($which_connection='')
 
 commit_transaction ($which_connection='')
 
 rollback_transaction ($which_connection='')
 
 test ($which_connection='')
 
 transfer ($source_db, $select_query, $dest_db, $insert_query)
 
 safeTransfer ($source_db, $select_query, $select_args, $dest_db, $insert_query)
 
 cleanDateTime ($str)
 
 table_exists ($table_name, $which_connection='')
 
 isView ($table_name, $which_connection='')
 
 getViewDefinition ($view_name, $which_connection='')
 
 table_definition ($table_name, $which_connection='')
 
 smart_insert ($table_name, $values, $which_connection='')
 
 datediff ($date1, $date2, $which_connection='')
 
 yeardiff ($date1, $date2, $which_connection='')
 
 now ($which_connection='')
 
 curdate ($which_connection='')
 
 dayofweek ($col, $which_connection='')
 
 curtime ($which_connection='')
 
 escape ($str, $which_connection='')
 
 identifierEscape ($str, $which_connection='')
 
 identifier_escape ($str, $which_connection='')
 
 sep ($which_connection='')
 
 dbms_name ($which_connection='')
 
 error ($which_connection='')
 
 concat ()
 
 convert ($expr, $type, $which_connection='')
 
 addSelectLimit ($query, $int_limit, $which_connection='')
 
 setTestData ($records)
 
 getTestDataRow ()
 
 logger ($str)
 

Static Public Member Functions

static sqlite_right ($str, $num)
 
static sqlite_space ($num)
 
static sqlite_replace ($field, $original, $new)
 

Public Attributes

 $connections
 
 $db_types
 
 $default_db
 

Detailed Description

Custom abstraction layer for SQL

Please see Fannie. It's the same class and tons of documentation to reproduce here.

Member Function Documentation

SQLManager::addSelectLimit (   $query,
  $int_limit,
  $which_connection = '' 
)

Add row limit to a select query

Parameters
$queryThe select query
$int_limitMax rows
which_connectionsee method close

This method currently only suport MySQL and MSSQL

SQLManager::close (   $which_connection = '',
  $force = false 
)

This is effectively disabled. Singleton behavior means it isn't really necessary

SQLManager::commit_transaction (   $which_connection = '')

Commit an SQL transaction

SQLManager::concat ( )

Concatenate strings

Parameters
Arbitrary;see below
Returns
The SQL expression

This function takes an arbitrary number of arguments and concatenates them. The last argument is the standard $which_connection but in this case it is not optional. You may pass the empty string to use the default database though.

This method currently only supports MySQL and MSSQL

SQLManager::convert (   $expr,
  $type,
  $which_connection = '' 
)

Get a SQL convert function

Parameters
$exprAn SQL expression
$typeConvert to this SQL type
$which_connectionsee method close()
Returns
The SQL expression

This method currently only supports MySQL and MSSQL

SQLManager::db_close (   $which_connection = '',
  $force = false 
)

Temporary compatibility solution. Will go away once db_close() calls are gone in all branches

SQLManager::exec_statement (   $stmt,
  $args = array(),
  $which_connection = '' 
)

execute statement: exec is emulated for non-PDO types

SQLManager::getViewDefinition (   $view_name,
  $which_connection = '' 
)

Get SQL definition of a view

Parameters
$view_namestring name
$which_connection[optional]
Returns
[string] SQL statement or [boolean] false
SQLManager::insert_id (   $which_connection = '')

Get last insert ID

Returns
[integer] last ID
SQLManager::logger (   $str)

Log a string to the query log.

Parameters
$strThe string
Returns
A True on success, False on failure
SQLManager::prepare_statement (   $query_text,
  $which_connection = '' 
)

Prepared statement: non-PDO types just return the query_text without modification

SQLManager::rollback_transaction (   $which_connection = '')

Rollback an SQL transaction

static SQLManager::sqlite_right (   $str,
  $num 
)
static

Supplementary functionality that SQLite doesn't have natively

SQLManager::start_transaction (   $which_connection = '')

Start a SQL transaction Nexted transactions not supported on MSSQL

SQLManager::transfer (   $source_db,
  $select_query,
  $dest_db,
  $insert_query 
)
LOGGED BY query() method

if (is_writable(DEBUG_MYSQL_QUERIES)) { $fp = fopen(DEBUG_MYSQL_QUERIES,"a"); fwrite($fp,$q."\n\n"); fclose($fp); }


The documentation for this class was generated from the following file: