Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

pdo.errorcode(3) [php man page]

PDO.ERRORCODE(3)							 1							  PDO.ERRORCODE(3)

PDO
::errorCode - Fetch the SQLSTATE associated with the last operation on the database handle SYNOPSIS
public mixed PDO::errorCode (void ) DESCRIPTION
RETURN VALUES
Returns an SQLSTATE, a five characters alphanumeric identifier defined in the ANSI SQL-92 standard. Briefly, an SQLSTATE consists of a two characters class value followed by a three characters subclass value. A class value of 01 indicates a warning and is accompanied by a return code of SQL_SUCCESS_WITH_INFO. Class values other than '01', except for the class 'IM', indicate an error. The class 'IM' is spe- cific to warnings and errors that derive from the implementation of PDO (or perhaps ODBC, if you're using the ODBC driver) itself. The sub- class value '000' in any class indicates that there is no subclass for that SQLSTATE. PDO.errorCode(3) only retrieves error codes for operations performed directly on the database handle. If you create a PDOStatement object through PDO.prepare(3) or PDO.query(3) and invoke an error on the statement handle, PDO.errorCode(3) will not reflect that error. You must call PDOStatement.errorCode(3) to return the error code for an operation performed on a particular statement handle. Returns NULL if no operation has been run on the database handle. EXAMPLES
Example #1 Retrieving an SQLSTATE code <?php /* Provoke an error -- the BONES table does not exist */ $dbh->exec("INSERT INTO bones(skull) VALUES ('lucy')"); echo " PDO::errorCode(): ", $dbh->errorCode(); ?> The above example will output: PDO::errorCode(): 42S02 SEE ALSO
PDO.errorInfo(3), PDOStatement.errorCode(3), PDOStatement.errorInfo(3). PHP Documentation Group PDO.ERRORCODE(3)

Check Out this Related Man Page

PDO.GETATTRIBUTE(3)							 1						       PDO.GETATTRIBUTE(3)

PDO
::getAttribute - Retrieve a database connection attribute SYNOPSIS
public mixed PDO::getAttribute (int $attribute) DESCRIPTION
This function returns the value of a database connection attribute. To retrieve PDOStatement attributes, refer to PDOStatement.getAt- tribute(3). Note that some database/driver combinations may not support all of the database connection attributes. PARAMETERS
o $attribute - One of the PDO::ATTR_* constants. The constants that apply to database connections are as follows: o PDO::ATTR_AUTOCOMMIT o PDO::ATTR_CASE o PDO::ATTR_CLIENT_VERSION o PDO::ATTR_CONNECTION_STATUS o PDO::ATTR_DRIVER_NAME o PDO::ATTR_ERRMODE o PDO::ATTR_ORACLE_NULLS o PDO::ATTR_PERSISTENT o PDO::ATTR_PREFETCH o PDO::ATTR_SERVER_INFO o PDO::ATTR_SERVER_VERSION o PDO::ATTR_TIMEOUT RETURN VALUES
A successful call returns the value of the requested PDO attribute. An unsuccessful call returns null. EXAMPLES
Example #1 Retrieving database connection attributes <?php $conn = new PDO('odbc:sample', 'db2inst1', 'ibmdb2'); $attributes = array( "AUTOCOMMIT", "ERRMODE", "CASE", "CLIENT_VERSION", "CONNECTION_STATUS", "ORACLE_NULLS", "PERSISTENT", "PREFETCH", "SERVER_INFO", "SERVER_VERSION", "TIMEOUT" ); foreach ($attributes as $val) { echo "PDO::ATTR_$val: "; echo $conn->getAttribute(constant("PDO::ATTR_$val")) . " "; } ?> SEE ALSO
PDO.setAttribute(3), PDOStatement.getAttribute(3), PDOStatement.setAttribute(3). PHP Documentation Group PDO.GETATTRIBUTE(3)
Man Page