KjwMySql Class Reference
[Database (SQL) handling]

KjwMySql is the mysql implementation of the KjwSql abstract class. More...

Inheritance diagram for KjwMySql:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 KjwMySql ($hostname, $portnum, $username, $password, $database)
 Construct a KjwMySql 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.
 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.

Public Attributes

 $_dbconn
 Database resource.


Detailed Description

KjwMySql is the mysql implementation of the KjwSql abstract class.

Todo:
See MsSql timeout/database fail 'transient_error' handling.

mysql_set_charset to CHARSET or something.. (if php >= 5.2.3)

Definition at line 32 of file KjwMySql.php.


Member Function Documentation

KjwMySql::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.

Returns:
The number of rows affected.
Note:
Don't try to be funny and do SELECT or whatever queries before calling this.

Reimplemented from KjwSql.

Definition at line 120 of file KjwMySql.php.

KjwMySql::connect (  ) 

Connect to the SQL server.

Returns:
True.
Todo:
Put timing on connect, so we don't have to wait 60secs on firewalled server.

Reimplemented from KjwSql.

Definition at line 56 of file KjwMySql.php.

References KjwObject::croak(), and KjwObject::trace().

Referenced by execute(), and safeQuote().

KjwMySql::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 50 of file KjwMySql.php.

References disconnect().

KjwMySql::disconnect (  ) 

Disconnect from the SQL server.

Returns:
Success boolean.

Reimplemented from KjwSql.

Definition at line 77 of file KjwMySql.php.

Referenced by destroy().

KjwMySql::execute ( query  ) 

Execute a query.

Parameters:
$query The query to execute.
Returns:
Returns a boolean specifying success or a KjwResult object on a select/show/describe/explain.

Reimplemented from KjwSql.

Definition at line 92 of file KjwMySql.php.

References KjwSql::_setLastQuery(), connect(), and KjwObject::croak().

Referenced by beginWork().

KjwMySql::insertId (  ) 

Returns the id of the last INSERT clause that uses an IDENTITY/SEQUENCE/AUTO_INCREMENT value.

Returns:
The new id.
Note:
Don't try to be funny and do SELECT or whatever queries before calling this.

Reimplemented from KjwSql.

Definition at line 125 of file KjwMySql.php.

KjwMySql::KjwMySql ( hostname,
portnum,
username,
password,
database 
)

Construct a KjwMySql object.

Parameters:
$hostname Server name or IP.
$portnum Port number of 0 if default.
$username User name.
$password Password.
$database Database name.

Definition at line 44 of file KjwMySql.php.

References KjwSql::KjwSql().

KjwMySql::nameQuote ( string  ) 

Quote a name for an object (column or table).

For MySQL this would be by surrounding the name with backticks.

Parameters:
$string An identifier (column or table name) to be quoted.
Returns:
The quoted identifier.

Reimplemented from KjwSql.

Definition at line 114 of file KjwMySql.php.

KjwMySql::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.

Parameters:
$mixed The variable that needs to be returned as a safe entity.
Returns:
A quoted/escaped entity.

Reimplemented from KjwSql.

Definition at line 104 of file KjwMySql.php.

References connect().


The documentation for this class was generated from the following file:

Generated on Wed Apr 8 22:16:35 2009 for KjwLib-php45 by  doxygen 1.5.8