Class miDBUtilImpl

Description

Implements functions for database

  • copyright: Copyright (c) 2003-2006 Mirchev Ideas Ltd. All rights reserved.

Located in /database/DBUtilImpl.php (line 20)


	
			
Variable Summary
mixed $_dbHost
mixed $_dbName
mixed $_dbPass
mixed $_dbUser
mixed $_link
Method Summary
miDBUtilImpl __construct (string $dbHost, string $dbUser, string $dbPass, string $dbName)
void execDelete (string $table, string $key, int $keyval)
int execInsert (string $table, array $values)
array execSelect (string $query, [array $params = array()])
array execSelectAndGetFields (string $query,  &$fieldsArray, array $fieldsArray)
mixed &execSQL (string $query, [array $params = array()])
int execSQLInsert (string $query)
void execUpdate (string $table, array $values, string $key, int $keyval)
array &getTableFields (string $table)
resource pconnect ()
false ping ()
Variables
mixed $_dbHost (line 32)
  • access: protected
mixed $_dbName (line 50)
  • access: protected
mixed $_dbPass (line 44)
  • access: protected
mixed $_dbUser (line 38)
  • access: protected
mixed $_link = null (line 26)
  • access: protected
Methods
Constructor __construct (line 68)

miDBUtilImpl constructor.

Example:

  1.  <?php
  2.  $DBUtilImpl new miDBUtilImpl($dbHost$dbUser$dbPass$dbName);
  3.  ?>

  • access: public
miDBUtilImpl __construct (string $dbHost, string $dbUser, string $dbPass, string $dbName)
  • string $dbHost: host name
  • string $dbUser: username
  • string $dbPass: password
  • string $dbName: database name
execDelete (line 385)

Executes a SQL delete query for a specify record key

Example:

  1.  <?php
  2.  $DBUtilImpl new miDBUtilImpl($dbHost$dbUser$dbPass$dbName);
  3.  $DBUtilImpl->pconnect();
  4.  $DBUtilImpl->execDelete($table$key$keyval);
  5.  ?>

  • throws: miDBException
  • access: public
void execDelete (string $table, string $key, int $keyval)
  • string $table: database table name
  • string $key: name of the key field
  • int $keyval: value of the key field
execInsert (line 303)

Executes a SQL insert query from an associative array.

Associative array is representing one record where keys are the table fields names. Example:

  1.  <?php
  2.  $DBUtilImpl new miDBUtilImpl($dbHost$dbUser$dbPass$dbName);
  3.  $DBUtilImpl->pconnect();
  4.  //$values is an associative array with data for inserting
  5.  $DBUtilImpl->execInsert($table$values);
  6.  ?>

  • return: the ID generated for an AUTO_INCREMENT column by the previous INSERT query or 0 if the previous query does not generate an AUTO_INCREMENT value
  • throws: miDBException
  • access: public
int execInsert (string $table, array $values)
  • string $table: table name
  • array $values: associative arrays with data for inserting
execSelect (line 224)

Returns an array with associative arrays from the result

Example:

  1.  <?php
  2.  $DBUtilImpl new miDBUtilImpl($dbHost$dbUser$dbPass$dbName);
  3.  $DBUtilImpl->pconnect();
  4.  $rows $DBUtilImpl->execSelect($query)
  5.  ?>

  • return: array with associative arrays from the result
  • throws: miDBException
  • access: public
array execSelect (string $query, [array $params = array()])
  • string $query: query string
  • array $params: positional query params (optional)
execSelectAndGetFields (line 258)

Executes the select query and also returns the selected column names in the $fieldsArray

Example:

  1.  <?php
  2.  $DBUtilImpl new miDBUtilImpl($dbHost$dbUser$dbPass$dbName);
  3.  $DBUtilImpl->pconnect();
  4.  $rows $DBUtilImpl->execSelectAndGetFields($query$fieldsArray);
  5.  ?>

  • return: array with associative arrays from the result
  • throws: miDBException
  • access: public
array execSelectAndGetFields (string $query,  &$fieldsArray, array $fieldsArray)
  • string $query: query string
  • array $fieldsArray: array for names of the fields
  • &$fieldsArray
execSQL (line 150)

Executes a SQL query

Example:

  1.  <?php
  2.  $DBUtilImpl new miDBUtilImpl($dbHost$dbUser$dbPass$dbName);
  3.  $DBUtilImpl->pconnect();
  4.  $rezult $DBUtilImpl->execSQL($query);
  5.  ?>

  • return: Resource identifier or true depending on the query
  • throws: miDBException
  • access: public
mixed &execSQL (string $query, [array $params = array()])
  • string $query: query string
  • array $params: positional params (optional)
execSQLInsert (line 190)

Executes a SQL insert query

Example:

  1.  <?php
  2.  $DBUtilImpl new miDBUtilImpl($dbHost$dbUser$dbPass$dbName);
  3.  $DBUtilImpl->pconnect();
  4.  $result $DBUtilImpl->execSQLInsert($query);
  5.  ?>

  • return: the ID generated for an AUTO_INCREMENT column by the previous INSERT query or 0 if the previous query does not generate an AUTO_INCREMENT value
  • throws: miDBException
  • access: public
int execSQLInsert (string $query)
  • string $query: query string
execUpdate (line 342)

Executes a SQL update query from an array for a specify record key

Example:

  1.  <?php
  2.  $DBUtilImpl new miDBUtilImpl($dbHost$dbUser$dbPass$dbName);
  3.  $DBUtilImpl->pconnect();
  4.  $DBUtilImpl->execUpdate($table$values$key$keyval);
  5.  ?>

  • throws: miDBException
  • access: public
void execUpdate (string $table, array $values, string $key, int $keyval)
  • string $table: database table name
  • array $values: associative arrays with data for updating
  • string $key: name of the key field
  • int $keyval: value of the key field
getTableFields (line 416)

Returns an array with names of the fields in the specified table.

Example:

  1.  <?php
  2.  $DBUtilImpl new miDBUtilImpl($dbHost$dbUser$dbPass$dbName);
  3.  $DBUtilImpl->pconnect();
  4.  $fieldsArray $DBUtilImpl->getTableFields($tableName);
  5.  ?>

  • return: array with names of the fields
  • throws: miDBException
  • access: public
array &getTableFields (string $table)
  • string $table: database table name
pconnect (line 92)

Connects to a SQL database

Example:

  1.  <?php
  2.  $DBUtilImpl new miDBUtilImpl($dbHost$dbUser$dbPass$dbName);
  3.  $DBUtilImpl->pconnect();
  4.  ?>

  • return: Returns a SQL link identifier
  • throws: miDBException
  • access: public
resource pconnect ()
ping (line 118)

Ping the database and attempt to reconnect if necessary

  • return: on failure, true on success
  • access: public
false ping ()

Documentation generated on Thu, 08 May 2008 16:57:23 +0300 by phpDocumentor 1.4.1