Packageindex Classtrees Modulegroups Elementlist Report XML Files

Softerra

sqlStorage

sqlStorage

public class sqlStorage

SQL Storage Abstraction Layer Class.

Simple wrapper class for SQL.

Linkshttp://www.softerra.com/products/ - [Softerra PHP Developer Library Home Page]
AuthorsSofterra <phplib@softerra.com>
SincePHP 4.0.1pl2
Version1.3.7
Copyright(c) 1999-2002 Softerra, LLC

 

Public Method Summary

void sqlStorage()
SQL Storage Class Constructor.
string getServer()
Get type of SQL server to connect to.
void debugOn()
Turns SQL debugger on.
void debugOff()
Turns SQL debugger off.
void connect(string $host, string $user, string $password, string $name)
Connects to SQL Server.
void close()
Disconnects from SQL server.
void select_db(string $database)
Selects an SQL database.
array list_dbs()
Lists databases available on SQL server.
array list_tables([ string $database ])
Lists tables contained in SQL database.
array list_fields(string $table, [ string $database ])
Lists SQL result fields.
string error()
Returns error message from the previous SQL operation.
integer free_result()
Frees result memory.
mixed query(string $query)
Sends an SQL query.
integer affected_rows()
Gets the number of rows affected during previous SQL operation.
mixed select(mixed $tables, [ mixed $fields, mixed $conditions ])
Sends an SQL SELECT query.
mixed update(string $table, array $values, [ mixed $conditions ])
Sends an SQL UPDATE query.
mixed insert(string $table, array $values)
Sends an SQL INSERT query.
mixed delete(string $table, [ mixed $conditions ])
Sends an SQL DELETE query.
mixed result([ integer $row, mixed $field ])
Gets result data.
integer num_rows()
Gets the number of rows in result.
integer num_fields()
Gets the number of fields in result.
mixed fetch_row()
Get a result row as an enumerated array.
array fetch_array()
Fetch a result row as an associative array.
mixed fetch_object([ integer $type ])
Fetch a result row as an object.
object stdClass fetch_field(integer $offset)
Gets column information from a result and returns it as an object.
array fetch_fields()
Gets column information from a result and returns it as an array of objects.
mixed fetch_result([ integer $format ])
Fetches all rows of result data into a multi-dimensional array.
array fetch_rows()
Fetches all rows of result data into a multi-dimensional array.
array fetch_arrays()
Fetches all rows of result data into a multi-dimensional array.
array fetch_objects()
Fetches all rows of result data.
integer insert_id()
Gets the ID generated from the previous INSERT operation.
boolean queryresult_exists()
Check if the previous SELECT operation returns result data.
mixed queryresult_record()
Fetches next row and returns the first field value.
array queryresult_column()
Fetches all rows of result data and returns the first column values.
boolean select_exists(mixed $tables, [ mixed $conditions ])
Sends a SELECT query and checks if the result data is not empty.
integer select_count(mixed $tables, [ mixed $conditions ])
Prepares and sends a SELECT query to count the number of rows for the specified conditions.
integer select_record(mixed $tables, mixed $fields, [ mixed $conditions ])
Sends a SELECT query and returns value of the first row and the first field.
array select_row(mixed $tables, mixed $fields, [ mixed $conditions ])
Sends a SELECT query and returns the first result row as an associative array.
array select_column(mixed $tables, mixed $fields, [ mixed $conditions ])
Sends a SELECT query and returns the first column values.
mixed select_result(mixed $tables, mixed $fields, [ mixed $conditions, integer $format ])
Sends a SELECT query and returns all rows of result data as a multi-dimensional array.
array search(string $expression, string $table, [ string $field, mixed $fields, integer $type, array $limit ])
Prepares and sends a SELECT query according to the specified expression.

Private Method Summary

boolean sal_unsupported_method(string $method)
Printing error message.

Private Field Summary

boolean $debug
Debug flag.
string $debugmessage
Debug message.
integer $connection
Connection link ID.
integer $queryresult
Result data link ID.
integer $database
DB link ID.
integer $query_count
Query counter.

Private Constant Summary

strErrorConnect >>Fatal: Can't connect to database.\n<< Connection error message.
strErrorSelect >>Fatal: Can't select from database.\n<< Selection error message.
fmtRow >>1<< Row format type.
fmtArr >>2<< Array format type.
fmtObj >>3<< Object format type.

Included files Summary, Type: require_once

mysql.fun.php MySQL SQL Abstraction Layer
lib.cfg.php Library configuration settings.
corban.lib.php "Corban, dear" - Debug Output Library.
sqlcompose.lib.php Simple SQL Query Compose Library.
sqlsearch.lib.php SQL Keywords Search Library.

Public Method Details

sqlStorage

public void sqlStorage( )

  SQL Storage Class Constructor.

Returns void


getServer

public string getServer( )

  Get type of SQL server to connect to.

Returns string

SQL server type, e.g. "MySQL".

Required global variables
boolean $salServer SQL server type.

debugOn

public void debugOn( )

  Turns SQL debugger on.

Returns void


debugOff

public void debugOff( )

  Turns SQL debugger off.

Returns void


connect

public void connect( string $host, string $user, string $password, string $name )

  Connects to SQL Server.

Stops HTML output and displays error message on failure.

Parameter
string $host
The hostname string can also include a port number. E.g. "hostname:port".
string $user
User name
string $password
Password
string $name
DB name
Returns void

See Also close()

close

public void close( )

  Disconnects from SQL server.

This isn't usually necessary, as non-persistent open links are automatically closed at the end of the script's execution.

Returns void

See Also connect()

select_db

public void select_db( string $database )

  Selects an SQL database.

Sets the current active database on the server.

Parameter
string $database
DB name
Returns void

See Also connect()

list_dbs

public array list_dbs( )

  Lists databases available on SQL server.

Returns an array of database names available from the current sql daemon.

Returns array

Database names.

See Also list_tables(), list_fields()

list_tables

public array list_tables( [ string $database ] )

  Lists tables contained in SQL database.

Takes a database name and returns an array of table names.

Parameter
string $database = >>""<<
DB Name.
Returns array

Table names.

See Also list_dbs(), list_fields()

list_fields

public array list_fields( string $table, [ string $database ] )

  Lists SQL result fields.

Takes a table name and returns an array of field names.

Parameter
string $table
Table Name.
string $database = >>""<<
DB Name (optional).
Returns array

Field names.

See Also list_dbs(), list_tables()

error

public string error( )

  Returns error message from the previous SQL operation.

Returns error message text from the previous SQL operation or an empty string if no error occurred.

Returns string


free_result

public integer free_result( )

  Frees result memory.

Only needs to be called if you are worried about using too much memory while your script is running. All associated result memory for the specified result identifier will automatically be freed.

Returns integer


query

public mixed query( string $query )

  Sends an SQL query.

The query string should not end with a semicolon. Returns SQL result on success, or FALSE on error.

Parameter
string $query
SQL query.
Returns mixed

SQL result on success, or FALSE on error.

See Also select(), update(), insert(), delete()

affected_rows

public integer affected_rows( )

  Gets the number of rows affected during previous SQL operation.

Returns the number of rows affected by the last INSERT, UPDATE or DELETE query. If the last query was a DELETE query with no WHERE clause, all of the records will have been deleted from the table but this function will return zero. This method is not effective for SELECT statements, only on statements which modify records.

Returns integer

See Also num_rows()

select

public mixed select( mixed $tables, [ mixed $fields, mixed $conditions ] )

  Sends an SQL SELECT query.

Returns SQL result on success, or FALSE on error.

Parameter
mixed $tables
Table name(s) - array or string.
mixed $fields = >>"*"<<
Field name(s) - array or string. If not specified, select all fields.
mixed $conditions = >>""<<
Condition - array or string.
Returns mixed

SQL result on success, or FALSE on error.

See Also query(), select_count(), select_exists(), select_record(), select_row(), select_column(), select_result()

update

public mixed update( string $table, array $values, [ mixed $conditions ] )

  Sends an SQL UPDATE query.

Returns SQL result on success, or FALSE on error.

Parameter
string $table
Table name.
array $values
An associative array contains field name(s) as key(s).
mixed $conditions = >>""<<
Condition - array or string.
Returns mixed

SQL result on success, or FALSE on error.

See Also query()

insert

public mixed insert( string $table, array $values )

  Sends an SQL INSERT query.

Returns SQL result on success, or FALSE on error.

Parameter
string $table
Table name.
array $values
An associative array contains field name(s) as key(s).
Returns mixed

SQL result on success, or FALSE on error.

See Also query(), insert_id()

delete

public mixed delete( string $table, [ mixed $conditions ] )

  Sends an SQL DELETE query.

Returns SQL result on success, or FALSE on error.

Parameter
string $table
Table name.
mixed $conditions = >>""<<
Condition - array or string.
Returns mixed

SQL result on success, or FALSE on error.

See Also query()

result

public mixed result( [ integer $row, mixed $field ] )

  Gets result data.

Returns the contents of one cell from an SQL result set. The field argument can be the field's offset, or the field's name, or the field's table dot field's name (fieldname.tablename). If the column name has been aliased ('select foo as bar from...'), use the alias instead of the column name.

Parameter
integer $row = >>0<<
mixed $field = >>0<<
Field name - integer or string.
Returns mixed

The contents of one cell from a SQL result set.

See Also fetch_row(), fetch_array(), fetch_object(), fetch_field(), fetch_fields(), fetch_result(), fetch_rows(), fetch_arrays(), fetch_objects()

num_rows

public integer num_rows( )

  Gets the number of rows in result.

This method is only valid for SELECT statements. To retrieve the number of rows returned from an INSERT, UPDATE or DELETE query, use affected_rows().

Returns integer

The number of rows in a result set.

See Also affected_rows(), num_fields()

num_fields

public integer num_fields( )

  Gets the number of fields in result.

This method is only valid for SELECT statements.

Returns integer

The number of fields in result has been preset.

See Also num_rows()

fetch_row

public mixed fetch_row( )

  Get a result row as an enumerated array.

Returns an array that corresponds to the fetched row, or FALSE if there are no more rows. Fetch one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.

Returns mixed

Array that corresponds to the fetched row, or FALSE if there are no more rows.

See Also result(), fetch_array(), fetch_object(), fetch_field(), fetch_fields(), fetch_result(), fetch_rows(), fetch_arrays(), fetch_objects()

fetch_array

public array fetch_array( )

  Fetch a result row as an associative array.

Returns an array that corresponds to the fetched row, or FALSE if there are no more rows. In addition to storing the data in the numeric indices of the result array, it also stores the data in associative indices, using the field names as keys.

Returns array

Array that corresponds to the fetched row, or FALSE if there are no more rows.

See Also result(), fetch_row(), fetch_object(), fetch_field(), fetch_fields(), fetch_result(), fetch_rows(), fetch_arrays(), fetch_objects()

fetch_object

public mixed fetch_object( [ integer $type ] )

  Fetch a result row as an object.

Returns an object with properties that correspond to the fetched row, or FALSE if there are no more rows.

Parameter
integer $type = >>0<<
Returns mixed

Object with properties that correspond to the fetched row, or FALSE if there are no more rows.

See Also result(), fetch_row(), fetch_array(), fetch_field(), fetch_fields(), fetch_result(), fetch_rows(), fetch_arrays(), fetch_objects()

fetch_field

public object stdClass fetch_field( integer $offset )

  Gets column information from a result and returns it as an object.

Returns an object containing field information. Can be used in order to obtain information about fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by fetch_field() is retrieved.

Parameter
integer $offset
Field offset.
Returns object stdClass

Object containing field information.

See Also result(), fetch_row(), fetch_array(), fetch_object(), fetch_fields(), fetch_result(), fetch_rows(), fetch_arrays(), fetch_objects()

fetch_fields

public array fetch_fields( )

  Gets column information from a result and returns it as an array of objects.

Can be used in order to obtain information about fields in a certain query result.

Returns array

Array of objects containing field information.

See Also result(), fetch_row(), fetch_array(), fetch_object(), fetch_field(), fetch_result(), fetch_rows(), fetch_arrays(), fetch_objects()

fetch_result

public mixed fetch_result( [ integer $format ] )

  Fetches all rows of result data into a multi-dimensional array.

Returns a multi-dimensional array[row][field] or array[row] of objects depending on $format parameter.

Parameter
integer $format = >>1<<
Accept the following constants: fmtRow, fmtArr, fmtObj.
Returns mixed

See Also result(), fetch_row(), fetch_array(), fetch_object(), fetch_field(), fetch_fields(), fetch_rows(), fetch_arrays(), fetch_objects()

fetch_rows

public array fetch_rows( )

  Fetches all rows of result data into a multi-dimensional array.

Returns a multi-dimensional array[row][field].

Returns array

See Also result(), fetch_row(), fetch_array(), fetch_object(), fetch_field(), fetch_fields(), fetch_result(), fetch_arrays(), fetch_objects()

fetch_arrays

public array fetch_arrays( )

  Fetches all rows of result data into a multi-dimensional array.

Returns a multi-dimensional array[row][field].

Returns array

See Also result(), fetch_row(), fetch_array(), fetch_object(), fetch_field(), fetch_fields(), fetch_result(), fetch_rows(), fetch_objects()

fetch_objects

public array fetch_objects( )

  Fetches all rows of result data.

Returns an array[row] of objects.

Returns array

See Also result(), fetch_row(), fetch_array(), fetch_field(), fetch_fields(), fetch_result(), fetch_rows(), fetch_arrays(), fetch_objects()

insert_id

public integer insert_id( )

  Gets the ID generated from the previous INSERT operation.

Returns the ID generated for an AUTO_INCREMENTED field.

Returns integer

See Also insert()

queryresult_exists

public boolean queryresult_exists( )

  Check if the previous SELECT operation returns result data.

Returns TRUE if the previous SELECT operation returns result data, or FALSE.

Returns boolean

See Also queryresult_record(), queryresult_column()

queryresult_record

public mixed queryresult_record( )

  Fetches next row and returns the first field value.

Returns mixed

See Also queryresult_exists(), queryresult_column()

queryresult_column

public array queryresult_column( )

  Fetches all rows of result data and returns the first column values.

Returns array

See Also queryresult_record(), queryresult_exists()

select_exists

public boolean select_exists( mixed $tables, [ mixed $conditions ] )

  Sends a SELECT query and checks if the result data is not empty.

Parameter
mixed $tables
Table name(s) - array or string.
mixed $conditions = >>""<<
Condition - array or string.
Returns boolean

See Also select(), select_count(), select_record(), select_row(), select_column(), select_result()

select_count

public integer select_count( mixed $tables, [ mixed $conditions ] )

  Prepares and sends a SELECT query to count the number of rows for the specified conditions.

Parameter
mixed $tables
Table name(s) - array or string.
mixed $conditions = >>""<<
Condition - array or string.
Returns integer

See Also select(), select_exists(), select_record(), select_row(), select_column(), select_result()

select_record

public integer select_record( mixed $tables, mixed $fields, [ mixed $conditions ] )

  Sends a SELECT query and returns value of the first row and the first field.

Parameter
mixed $tables
Table name(s) - array or string.
mixed $fields
Field name(s) - array or string. If not specified, select all fields.
mixed $conditions = >>""<<
Condition - array or string.
Returns integer

See Also select(), select_count(), select_exists(), select_row(), select_column(), select_result()

select_row

public array select_row( mixed $tables, mixed $fields, [ mixed $conditions ] )

  Sends a SELECT query and returns the first result row as an associative array.

Parameter
mixed $tables
Table name(s) - array or string.
mixed $fields
Field name(s) - array or string. If not specified, select all fields.
mixed $conditions = >>""<<
Condition - array or string.
Returns array

See Also select(), select_count(), select_exists(), select_record(), select_column(), select_result()

select_column

public array select_column( mixed $tables, mixed $fields, [ mixed $conditions ] )

  Sends a SELECT query and returns the first column values.

Parameter
mixed $tables
Table name(s) - array or string.
mixed $fields
Field name(s) - array or string. If not specified, select all fields.
mixed $conditions = >>""<<
Condition - array or string.
Returns array

See Also select(), select_count(), select_exists(), select_record(), select_row(), select_result()

select_result

public mixed select_result( mixed $tables, mixed $fields, [ mixed $conditions, integer $format ] )

  Sends a SELECT query and returns all rows of result data as a multi-dimensional array.

Parameter
mixed $tables
Table name(s) - array or string.
mixed $fields
Field name(s) - array or string. If not specified, select all fields.
mixed $conditions = >>""<<
Condition - array or string.
integer $format = >>2<<
Accept the following constants: fmtRow, fmtArr, fmtObj
Returns mixed

See Also select(), select_count(), select_exists(), select_record(), select_row(), select_column()

search

public array search( string $expression, string $table, [ string $field, mixed $fields, integer $type, array $limit ] )

  Prepares and sends a SELECT query according to the specified expression.

Returns all rows of result data as a multi-dimensional array.

Parameter
string $expression
Expression.
string $table
Table name.
string $field = >>""<<
Field name.
mixed $fields = >>"*"<<
Field name(s) - array or string. If not specified, select all fields.
integer $type = >>0<<
Accept the following constants: SQL_PATTERN, REGEXP_PATTERN
array $limit = >>array()<<
Result data limit.
Returns array


Private Method Details

sal_unsupported_method

private boolean sal_unsupported_method( string $method )

  Printing error message.

Parameter
string $method
Returns boolean


Private Field Details

$debug

private boolean $debug

>><<

Debug flag.


$debugmessage

private string $debugmessage

>><<

Debug message.


$connection

private integer $connection

>><<

Connection link ID.


$queryresult

private integer $queryresult

>><<

Result data link ID.


$database

private integer $database

>><<

DB link ID.


$query_count

private integer $query_count

>><<

Query counter.


Private Constant Details

strErrorConnect

define( strErrorConnect, >>Fatal: Can't connect to database.\n<< )
Case: default: case sensitive

Connection error message.


strErrorSelect

define( strErrorSelect, >>Fatal: Can't select from database.\n<< )
Case: default: case sensitive

Selection error message.


fmtRow

define( fmtRow, >>1<< )
Case: default: case sensitive

Row format type.


fmtArr

define( fmtArr, >>2<< )
Case: default: case sensitive

Array format type.


fmtObj

define( fmtObj, >>3<< )
Case: default: case sensitive

Object format type.


Included Files, Type: require_once

mysql.fun.php

require_once( mysql.fun.php )

MySQL SQL Abstraction Layer

Version 1.2.4
Since PHP 4.0.1pl2
Copyright (c) 1999-2002 Softerra, LLC
Links http://www.softerra.com/products/ - [Softerra PHP Developer Library Home Page]
Authors Softerra <phplib@softerra.com>

lib.cfg.php

require_once( lib.cfg.php )

Library configuration settings.

Version 1.0.3
Since PHP 4.0.1pl2
Copyright (c) 1999-2002 Softerra, LLC
Links http://www.softerra.com/products/ - [Softerra PHP Developer Library Home Page]
Authors Softerra <phplib@softerra.com>

corban.lib.php

require_once( corban.lib.php )

"Corban, dear" - Debug Output Library.

Version 1.3.5
Since PHP 4.0.1pl2
Copyright (c) 1999-2002 Softerra, LLC
Links http://www.softerra.com/products/ - [Softerra PHP Developer Library Home Page]
Authors Softerra <phplib@softerra.com>

sqlcompose.lib.php

require_once( sqlcompose.lib.php )

Simple SQL Query Compose Library.

Version 1.3.5
Since PHP 4.0.1pl2
Copyright (c) 1999-2002 Softerra, LLC
Links http://www.softerra.com/products/ - [Softerra PHP Developer Library Home Page]
Authors Softerra <phplib@softerra.com>

sqlsearch.lib.php

require_once( sqlsearch.lib.php )

SQL Keywords Search Library.

Version 1.3.6
Since PHP 4.0.1pl2
Copyright (c) 1999-2002 Softerra, LLC
Links http://www.softerra.com/products/ - [Softerra PHP Developer Library Home Page]
Authors Softerra <phplib@softerra.com>


Packageindex Classtrees Modulegroups Elementlist Report XML Files