Class DB_mssql

Description

The methods PEAR DB uses to interact with PHP's mssql extension for interacting with Microsoft SQL Server databases

These methods overload the ones declared in DB_common.

DB's mssql driver is only for Microsfoft SQL Server databases.

If you're connecting to a Sybase database, you MUST specify "sybase" as the "phptype" in the DSN.

This class only works correctly if you have compiled PHP using --with-mssql=[dir_to_FreeTDS].

Located in /web/lib/external/pear-db/DB/mssql.php (line 55)

PEAR
   |
   --DB_common
      |
      --DB_mssql
Variable Summary
 resource $connection
 string $dbsyntax
 array $dsn
 array $features
 string $phptype
Method Summary
 void DB_mssql ()
 int affectedRows ()
 int autoCommit ([bool $onoff = false])
 int commit ()
 int connect (array $dsn, [bool $persistent = false])
 int createSequence (string $seq_name)
 bool disconnect ()
 int dropSequence (string $seq_name)
 integer errorCode ([mixed $nativecode = null], [ $msg = ''])
 int errorNative ()
 mixed fetchInto (resource $result,  &$arr, int $fetchmode, [int $rownum = null], array $arr)
 bool freeResult (resource $result)
 string getSpecialQuery (string $type)
 object the mssqlRaiseError ([ $code = null], int $errno)
 int nextId (string $seq_name, [boolean $ondemand = true])
 true nextResult (a $result)
 int numCols (resource $result)
 int numRows (resource $result)
 string quoteIdentifier (string $str)
 int rollback ()
 mixed simpleQuery (string $query)
 array tableInfo (object|string $result, [int $mode = null])
Variables
resource $connection (line 140)

The raw database connection created by PHP

string $dbsyntax = 'mssql' (line 69)

The database syntax variant to be used (db2, access, etc.), if any

array $dsn = array() (line 146)

The DSN information for connecting to a database

array $errorcode_map = array(
102 => DB_ERROR_SYNTAX,
110 => DB_ERROR_VALUE_COUNT_ON_ROW,
155 => DB_ERROR_NOSUCHFIELD,
156 => DB_ERROR_SYNTAX,
170 => DB_ERROR_SYNTAX,
207 => DB_ERROR_NOSUCHFIELD,
208 => DB_ERROR_NOSUCHTABLE,
245 => DB_ERROR_INVALID_NUMBER,
319 => DB_ERROR_SYNTAX,
321 => DB_ERROR_NOSUCHFIELD,
325 => DB_ERROR_SYNTAX,
336 => DB_ERROR_SYNTAX,
515 => DB_ERROR_CONSTRAINT_NOT_NULL,
547 => DB_ERROR_CONSTRAINT,
1018 => DB_ERROR_SYNTAX,
1035 => DB_ERROR_SYNTAX,
1913 => DB_ERROR_ALREADY_EXISTS,
2209 => DB_ERROR_SYNTAX,
2223 => DB_ERROR_SYNTAX,
2248 => DB_ERROR_SYNTAX,
2256 => DB_ERROR_SYNTAX,
2257 => DB_ERROR_SYNTAX,
2627 => DB_ERROR_CONSTRAINT,
2714 => DB_ERROR_ALREADY_EXISTS,
3607 => DB_ERROR_DIVZERO,
3701 => DB_ERROR_NOSUCHTABLE,
7630 => DB_ERROR_SYNTAX,
8134 => DB_ERROR_DIVZERO,
9303 => DB_ERROR_SYNTAX,
9317 => DB_ERROR_SYNTAX,
9318 => DB_ERROR_SYNTAX,
9331 => DB_ERROR_SYNTAX,
9332 => DB_ERROR_SYNTAX,
15253 => DB_ERROR_SYNTAX,
)
(line 99)

A mapping of native error codes to DB error codes

array $features = array(
'limit' => 'emulate',
'new_link' => false,
'numrows' => true,
'pconnect' => true,
'prepare' => false,
'ssl' => false,
'transactions' => true,
)
(line 84)

The capabilities of this DB implementation

The 'new_link' element contains the PHP version that first provided new_link support for this DBMS. Contains false if it's unsupported.

Meaning of the 'limit' element:

  • 'emulate' = emulate with fetch row by number
  • 'alter' = alter the query
  • false = skip rows

string $phptype = 'mssql' (line 63)

The DB driver type (mysql, oci8, odbc, etc.)

Inherited Variables

Inherited from DB_common

DB_common::$fetchmode
DB_common::$fetchmode_object_class
DB_common::$last_parameters
DB_common::$last_query
DB_common::$options
DB_common::$prepared_queries
DB_common::$prepare_tokens
DB_common::$prepare_types
DB_common::$was_connected
DB_common::$_last_query_manip
DB_common::$_next_query_manip
Methods
Constructor DB_mssql (line 186)

This constructor calls $this->DB_common()

void DB_mssql ()
affectedRows (line 513)

Determines the number of rows affected by a data maniuplation query

  1. is returned for queries that don't manipulate data.

  • return: the number of rows. A DB_Error object on failure.
int affectedRows ()

Redefinition of:
DB_common::affectedRows()
Determines the number of rows affected by a data maniuplation query
autoCommit (line 449)

Enables or disables automatic commits

  • return: DB_OK on success. A DB_Error object if the driver doesn't support auto-committing transactions.
int autoCommit ([bool $onoff = false])
  • bool $onoff: true turns it on, false turns it off

Redefinition of:
DB_common::autoCommit()
Enables or disables automatic commits
commit (line 465)

Commits the current transaction

  • return: DB_OK on success. A DB_Error object on failure.
int commit ()

Redefinition of:
DB_common::commit()
Commits the current transaction
connect (line 204)

Connect to the database server, log in and open the database

Don't call this method directly. Use DB::connect() instead.

  • return: DB_OK on success. A DB_Error object on failure.
int connect (array $dsn, [bool $persistent = false])
  • array $dsn: the data source name
  • bool $persistent: should the connection be persistent?
createSequence (line 600)

Creates a new sequence

int createSequence (string $seq_name)
  • string $seq_name: name of the new sequence

Redefinition of:
DB_common::createSequence()
Creates a new sequence
disconnect (line 255)

Disconnects from the database server

  • return: TRUE on success, FALSE on failure
bool disconnect ()
dropSequence (line 621)

Deletes a sequence

int dropSequence (string $seq_name)
  • string $seq_name: name of the sequence to be deleted

Redefinition of:
DB_common::dropSequence()
Deletes a sequence
errorCode (line 699)

Determines PEAR::DB error code from mssql's native codes.

If $nativecode isn't known yet, it will be looked up.

integer errorCode ([mixed $nativecode = null], [ $msg = ''])
  • mixed $nativecode: mssql error code, if known
  • $msg

Redefinition of:
DB_common::errorCode()
Maps native error codes to DB's portable ones
errorNative (line 677)

Gets the DBMS' native error code produced by the last query

  • return: the DBMS' error code
int errorNative ()

Redefinition of:
DB_common::errorNative()
Gets the DBMS' native error code produced by the last query
fetchInto (line 340)

Places a row from the result set into the given array

Formating of the array and the data therein are configurable. See DB_result::fetchInto() for more information.

This method is not meant to be called directly. Use DB_result::fetchInto() instead. It can't be declared "protected" because DB_result is a separate object.

  • return: DB_OK on success, NULL when the end of a result set is reached or on failure
  • see: DB_result::fetchInto()
mixed fetchInto (resource $result,  &$arr, int $fetchmode, [int $rownum = null], array $arr)
  • resource $result: the query result resource
  • array $arr: the referenced array to put the data in
  • int $fetchmode: how the resulting array should be indexed
  • int $rownum: the row number to fetch (0 = first row)
  • &$arr
freeResult (line 383)

Deletes the result set and frees the memory occupied by the result set

This method is not meant to be called directly. Use DB_result::free() instead. It can't be declared "protected" because DB_result is a separate object.

bool freeResult (resource $result)
  • resource $result: PHP's query result resource
getSpecialQuery (line 940)

Obtains the query string needed for listing a given type of objects

  • return: the SQL query string or null if the driver doesn't support the object type requested
  • see: DB_common::getListOf()
  • access: protected
string getSpecialQuery (string $type)
  • string $type: the kind of objects you want to retrieve

Redefinition of:
DB_common::getSpecialQuery()
Obtains the query string needed for listing a given type of objects
mssqlRaiseError (line 659)

Produces a DB_Error object regarding the current problem

object the mssqlRaiseError ([ $code = null], int $errno)
  • int $errno: if the error is being manually raised pass a DB_ERROR* constant here. If this isn't passed the error information gathered from the DBMS.
  • $code
nextId (line 549)

Returns the next free id in a sequence

int nextId (string $seq_name, [boolean $ondemand = true])
  • string $seq_name: name of the sequence
  • boolean $ondemand: when true, the seqence is automatically created if it does not exist

Redefinition of:
DB_common::nextId()
Returns the next free id in a sequence
nextResult (line 312)

Move the internal mssql result pointer to the next available result

  • return: if a result is available otherwise return false
  • access: public
true nextResult (a $result)
  • a $result: valid fbsql result resource
numCols (line 404)

Gets the number of columns in a result set

This method is not meant to be called directly. Use DB_result::numCols() instead. It can't be declared "protected" because DB_result is a separate object.

int numCols (resource $result)
  • resource $result: PHP's query result resource
numRows (line 429)

Gets the number of rows in a result set

This method is not meant to be called directly. Use DB_result::numRows() instead. It can't be declared "protected" because DB_result is a separate object.

int numRows (resource $result)
  • resource $result: PHP's query result resource

Redefinition of:
DB_common::numRows()
Determines the number of rows in a query result
quoteIdentifier (line 639)

Quotes a string so it can be safely used as a table or column name

string quoteIdentifier (string $str)
  • string $str: identifier name to be quoted

Redefinition of:
DB_common::quoteIdentifier()
Quotes a string so it can be safely used as a table or column name
rollback (line 488)

Reverts the current transaction

  • return: DB_OK on success. A DB_Error object on failure.
int rollback ()

Redefinition of:
DB_common::rollback()
Reverts the current transaction
simpleQuery (line 274)

Sends a query to the database server

  • return: + a PHP result resrouce for successful SELECT queries
    • the DB_OK constant for other successful queries
    • a DB_Error object on failure
mixed simpleQuery (string $query)
  • string $query: the SQL query string
tableInfo (line 737)

Returns information about a table or a result set

NOTE: only supports 'table' and 'flags' if $result is a table name.

  • return: an associative array with the information requested. A DB_Error object on failure.
  • see: DB_common::tableInfo()
array tableInfo (object|string $result, [int $mode = null])
  • object|string $result: DB_result object from a query or a string containing the name of a table. While this also accepts a query result resource identifier, this behavior is deprecated.
  • int $mode: a valid tableInfo mode

Redefinition of:
DB_common::tableInfo()
Returns information about a table or a result set

Inherited Methods

Inherited From DB_common

 DB_common::DB_common()
 DB_common::affectedRows()
 DB_common::autoCommit()
 DB_common::autoExecute()
 DB_common::autoPrepare()
 DB_common::buildManipSQL()
 DB_common::commit()
 DB_common::createSequence()
 DB_common::dropSequence()
 DB_common::errorCode()
 DB_common::errorMessage()
 DB_common::errorNative()
 DB_common::escapeSimple()
 DB_common::execute()
 DB_common::executeEmulateQuery()
 DB_common::executeMultiple()
 DB_common::freePrepared()
 DB_common::getAll()
 DB_common::getAssoc()
 DB_common::getCol()
 DB_common::getListOf()
 DB_common::getOne()
 DB_common::getOption()
 DB_common::getRow()
 DB_common::getSequenceName()
 DB_common::getSpecialQuery()
 DB_common::getTables()
 DB_common::limitQuery()
 DB_common::modifyLimitQuery()
 DB_common::modifyQuery()
 DB_common::nextId()
 DB_common::nextQueryIsManip()
 DB_common::numRows()
 DB_common::prepare()
 DB_common::provides()
 DB_common::query()
 DB_common::quote()
 DB_common::quoteBoolean()
 DB_common::quoteFloat()
 DB_common::quoteIdentifier()
 DB_common::quoteSmart()
 DB_common::quoteString()
 DB_common::raiseError()
 DB_common::rollback()
 DB_common::setFetchMode()
 DB_common::setOption()
 DB_common::tableInfo()
 DB_common::toString()
 DB_common::_checkManip()
 DB_common::_convertNullArrayValuesToEmpty()
 DB_common::_rtrimArrayValues()
 DB_common::__sleep()
 DB_common::__toString()
 DB_common::__wakeup()

Inherited From PEAR

 PEAR::PEAR()
 PEAR::delExpect()
 PEAR::expectError()
 PEAR::getStaticProperty()
 PEAR::isError()
 PEAR::loadExtension()
 PEAR::popErrorHandling()
 PEAR::popExpect()
 PEAR::pushErrorHandling()
 PEAR::raiseError()
 PEAR::registerShutdownFunc()
 PEAR::setErrorHandling()
 PEAR::staticPopErrorHandling()
 PEAR::staticPushErrorHandling()
 PEAR::throwError()
 PEAR::_PEAR()

Documentation generated on Wed, 09 Feb 2011 09:02:04 +0700 by phpDocumentor 1.4.2