It should be noted that PDO::FETCH_CLASS will call the constructor *after* setting the values (or calling __set).
The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.
PDO uses class constants since PHP 5.1. Prior releases use global constants
in the form PDO_PARAM_BOOL
.
PDO::PARAM_BOOL
(integer)
PDO::PARAM_NULL
(integer)
PDO::PARAM_INT
(integer)
PDO::PARAM_STR
(integer)
PDO::PARAM_LOB
(integer)
PDO::PARAM_STMT
(integer)
PDO::PARAM_INPUT_OUTPUT
(integer)
PDO::FETCH_LAZY
(integer)
PDO::FETCH_LAZY
creates the object variable names as they are accessed.
Not valid inside PDOStatement::fetchAll().
PDO::FETCH_ASSOC
(integer)
PDO::FETCH_ASSOC
returns
only a single value per column name.
PDO::FETCH_NAMED
(integer)
PDO::FETCH_NAMED
returns
an array of values per column name.
PDO::FETCH_NUM
(integer)
PDO::FETCH_BOTH
(integer)
PDO::FETCH_OBJ
(integer)
PDO::FETCH_BOUND
(integer)
PDO::FETCH_COLUMN
(integer)
PDO::FETCH_CLASS
(integer)
Note: The magic __set() method is called if the property doesn't exist in the requested class
PDO::FETCH_INTO
(integer)
PDO::FETCH_FUNC
(integer)
PDO::FETCH_GROUP
(integer)
PDO::FETCH_COLUMN
or
PDO::FETCH_KEY_PAIR
.
PDO::FETCH_UNIQUE
(integer)
PDO::FETCH_KEY_PAIR
(integer)
PDO::FETCH_CLASSTYPE
(integer)
PDO::FETCH_SERIALIZE
(integer)
PDO::FETCH_INTO
but object is provided as a serialized string.
Available since PHP 5.1.0. Since PHP 5.3.0 the class constructor is never called if this
flag is set.
PDO::FETCH_PROPS_LATE
(integer)
PDO::ATTR_AUTOCOMMIT
(integer)
FALSE
, PDO attempts to disable autocommit so that the
connection begins a transaction.
PDO::ATTR_PREFETCH
(integer)
PDO::ATTR_TIMEOUT
(integer)
PDO::ATTR_ERRMODE
(integer)
PDO::ATTR_SERVER_VERSION
(integer)
PDO::ATTR_CLIENT_VERSION
(integer)
PDO::ATTR_SERVER_INFO
(integer)
PDO::ATTR_CONNECTION_STATUS
(integer)
PDO::ATTR_CASE
(integer)
PDO::ATTR_CURSOR_NAME
(integer)
PDO::ATTR_CURSOR
(integer)
PDO::CURSOR_FWDONLY
and
PDO::CURSOR_SCROLL
. Stick with
PDO::CURSOR_FWDONLY
unless you know that you need a
scrollable cursor.
PDO::ATTR_DRIVER_NAME
(string)
Example #1 using PDO::ATTR_DRIVER_NAME
<?php
if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
echo "Running on mysql; doing something mysql specific here\n";
}
?>
PDO::ATTR_ORACLE_NULLS
(integer)
PDO::ATTR_PERSISTENT
(integer)
PDO::ATTR_STATEMENT_CLASS
(integer)
PDO::ATTR_FETCH_CATALOG_NAMES
(integer)
PDO::ATTR_FETCH_TABLE_NAMES
(integer)
PDO::ATTR_STRINGIFY_FETCHES
(integer)
PDO::ATTR_MAX_COLUMN_LEN
(integer)
PDO::ATTR_DEFAULT_FETCH_MODE
(integer)
PDO::ATTR_EMULATE_PREPARES
(integer)
PDO::ERRMODE_SILENT
(integer)
PDO::ERRMODE_WARNING
(integer)
E_WARNING
message if an error occurs.
See Errors and error handling
for more information about this attribute.
PDO::ERRMODE_EXCEPTION
(integer)
PDO::CASE_NATURAL
(integer)
PDO::CASE_LOWER
(integer)
PDO::CASE_UPPER
(integer)
PDO::NULL_NATURAL
(integer)
PDO::NULL_EMPTY_STRING
(integer)
PDO::NULL_TO_STRING
(integer)
PDO::FETCH_ORI_NEXT
(integer)
PDO::FETCH_ORI_PRIOR
(integer)
PDO::FETCH_ORI_FIRST
(integer)
PDO::FETCH_ORI_LAST
(integer)
PDO::FETCH_ORI_ABS
(integer)
PDO::FETCH_ORI_REL
(integer)
PDO::CURSOR_FWDONLY
(integer)
PDO::CURSOR_SCROLL
(integer)
PDO::ERR_NONE
(string)
PDO::PARAM_EVT_ALLOC
(integer)
PDO::PARAM_EVT_FREE
(integer)
PDO::PARAM_EVT_EXEC_PRE
(integer)
PDO::PARAM_EVT_EXEC_POST
(integer)
PDO::PARAM_EVT_FETCH_PRE
(integer)
PDO::PARAM_EVT_FETCH_POST
(integer)
PDO::PARAM_EVT_NORMALIZE
(integer)
It should be noted that PDO::FETCH_CLASS will call the constructor *after* setting the values (or calling __set).
If you're reading in information from an array to use in a prepared statement you may find the following function useful.
<?php
function getPDOConstantType( $var )
{
if( is_int( $var ) )
return PDO::PARAM_INT;
if( is_bool( $var ) )
return PDO::PARAM_BOOL;
if( is_null( $var ) )
return PDO::PARAM_NULL;
//Default
return PDO::PARAM_STR;
}
?>