Public Member Functions | |
KjwMsSql ($hostname, $portnum, $username, $password, $database) | |
Construct a KjwMsSql object. | |
destroy () | |
Destructor performing cleanup. | |
connect () | |
Connect to the SQL server. | |
disconnect () | |
Disconnect from the SQL server. | |
beginWork () | |
Begin a transaction / atomic operation. | |
execute ($query) | |
Execute a query. | |
executeLowLevel ($query) | |
A variant on the execute() method that does not reset/reselect the database and does not set the last_insert_id or error messages. | |
_execute_1 ($query) | |
Low level execute method internals, part 1. | |
_execute_2 ($query) | |
Low level execute method internals, part 2. | |
_execute_3 ($query) | |
Low level execute method internals, part 3. | |
_execute_4 ($sybase_result, $is_insert_update, $is_select) | |
Low level execute method internals, part 4. | |
safeQuote ($mixed) | |
Makes sure that any variable is quoted like its correct type should be. | |
nameQuote ($string) | |
Quote a name for an object (column or table). | |
affectedRows () | |
How many rows were affected (touched) by the last INSERT, UPDATE, REPLACE or DELETE query. | |
insertId () | |
Returns the id of the last INSERT clause that uses an IDENTITY/SEQUENCE/AUTO_INCREMENT value. | |
getLastMessage () | |
Returns the last info/error messages as a string. | |
_clearLastMessage () | |
Clear stored messages. | |
_messageHandler ($message, $severity, $state, $lineNumber, $description) | |
Message handler. | |
Public Attributes | |
$_dbconn | |
Database resource. | |
$_quotedDbname | |
Database name, quoted. | |
$_insertId | |
Insert ID / Identity ID of last query (insert/update). | |
$_affectedRows | |
Count of rows affected with last query (insert/update). | |
$_messages | |
Server error messages. |
Uses the KJW_DIE_ON_TRANSIENT_ERROR define.
Definition at line 34 of file KjwMsSql.php.
KjwMsSql::_clearLastMessage | ( | ) |
Clear stored messages.
Used internally only.
Definition at line 305 of file KjwMsSql.php.
Referenced by _execute_3().
KjwMsSql::_execute_1 | ( | $ | query | ) |
Low level execute method internals, part 1.
$query | The query to execute. |
Definition at line 172 of file KjwMsSql.php.
References KjwSql::_setLastQuery(), and connect().
Referenced by execute(), and executeLowLevel().
KjwMsSql::_execute_2 | ( | $ | query | ) |
Low level execute method internals, part 2.
$query | The query to execute. |
Definition at line 188 of file KjwMsSql.php.
Referenced by execute().
KjwMsSql::_execute_3 | ( | $ | query | ) |
Low level execute method internals, part 3.
$query | The query to execute. |
Definition at line 216 of file KjwMsSql.php.
References _clearLastMessage(), KjwSql::_getLastQuery(), KjwObject::croak(), and getLastMessage().
Referenced by execute(), and executeLowLevel().
KjwMsSql::_execute_4 | ( | $ | sybase_result, | |
$ | is_insert_update, | |||
$ | is_select | |||
) |
Low level execute method internals, part 4.
$sybase_result | A sybase resource. | |
$is_insert_update | True if the query was an insert or update statement. | |
$is_select | True if the query was a select statement. |
Definition at line 241 of file KjwMsSql.php.
Referenced by execute().
KjwMsSql::_messageHandler | ( | $ | message, | |
$ | severity, | |||
$ | state, | |||
$ | lineNumber, | |||
$ | description | |||
) |
Message handler.
We need to use this because the sybase_get_last_message stores only the latest message in a series of messages. Could be semi-private.. no one should reference it by name, but others should call it because it is a callback.
sybase_min_client_severity and sybase_min_server_severity decide which messages get passed to this callback.
$message | The error number. | |
$severity | The error severity (integer, likely 10 or above). | |
$state | Some kind of state (what\?). | |
$lineNumber | Line number. | |
$description | The error message as a string. |
Definition at line 324 of file KjwMsSql.php.
KjwMsSql::affectedRows | ( | ) |
How many rows were affected (touched) by the last INSERT, UPDATE, REPLACE or DELETE query.
It's unspecified if an UPDATE count includes updates that weren't actual changes. I.e. either the WHERE-match-count is returned, or only the subset where the update was a change.
Reimplemented from KjwSql.
Definition at line 279 of file KjwMsSql.php.
KjwMsSql::connect | ( | ) |
Connect to the SQL server.
Reimplemented from KjwSql.
Definition at line 67 of file KjwMsSql.php.
References $kjw_suppressed_error, KjwObject::croak(), KjwObject::getError(), getLastMessage(), nameQuote(), and KjwObject::setError().
Referenced by _execute_1().
KjwMsSql::destroy | ( | ) |
Destructor performing cleanup.
Don't rely on this being called ever. The user must call it by hand.
Reimplemented from KjwSql.
Definition at line 61 of file KjwMsSql.php.
References disconnect().
KjwMsSql::disconnect | ( | ) |
Disconnect from the SQL server.
Reimplemented from KjwSql.
Definition at line 109 of file KjwMsSql.php.
Referenced by destroy().
KjwMsSql::execute | ( | $ | query | ) |
Execute a query.
$query | The query to execute. |
Reimplemented from KjwSql.
Definition at line 124 of file KjwMsSql.php.
References _execute_1(), _execute_2(), _execute_3(), and _execute_4().
Referenced by beginWork().
KjwMsSql::executeLowLevel | ( | $ | query | ) |
A variant on the execute() method that does not reset/reselect the database and does not set the last_insert_id or error messages.
The normal execute does extra stuff to keep the behaviour compatible with the KjwSql standard. This one does not. You'll have to live with sybase_* and T-SQL specific weirdness.
If you use "USE <database>" statements in your queries, you want to use this one. *Note* *that* *you* *cannot* *use* *multiple* *KjwSql* *objects* *safely* when you're using this function. This one is perfect for executing a batch of create statements.
$query | The query to execute. |
Definition at line 152 of file KjwMsSql.php.
References _execute_1(), and _execute_3().
KjwMsSql::getLastMessage | ( | ) |
Returns the last info/error messages as a string.
Definition at line 298 of file KjwMsSql.php.
Referenced by _execute_3(), and connect().
KjwMsSql::insertId | ( | ) |
Returns the id of the last INSERT clause that uses an IDENTITY/SEQUENCE/AUTO_INCREMENT value.
Reimplemented from KjwSql.
Definition at line 288 of file KjwMsSql.php.
KjwMsSql::KjwMsSql | ( | $ | hostname, | |
$ | portnum, | |||
$ | username, | |||
$ | password, | |||
$ | database | |||
) |
Construct a KjwMsSql object.
$hostname | Server name or IP. | |
$portnum | Port number of 0 if default. | |
$username | User name. | |
$password | Password. | |
$database | Database name. |
Definition at line 50 of file KjwMsSql.php.
References KjwSql::KjwSql(), and nameQuote().
KjwMsSql::nameQuote | ( | $ | string | ) |
Quote a name for an object (column or table).
For MySQL this would be by surrounding the name with backticks.
$string | An identifier (column or table name) to be quoted. |
Reimplemented from KjwSql.
Definition at line 273 of file KjwMsSql.php.
Referenced by connect(), and KjwMsSql().
KjwMsSql::safeQuote | ( | $ | mixed | ) |
Makes sure that any variable is quoted like its correct type should be.
Integers and booleans are returned as integers. Strings are returned as quoted strings with all quotes escaped. If the escaping mechanism is not known, all <32 and >127 characters REMOVED, otherwise the escaping for the specific database make is used.
$mixed | The variable that needs to be returned as a safe entity. |
Reimplemented from KjwSql.
Definition at line 262 of file KjwMsSql.php.
KjwMsSql::$_affectedRows |
KjwMsSql::$_insertId |