Connects this object to the database.
Connects this object to the database. Connection objects are not necessarily created with a connection to the database so you might have to call this method to be able to run queries against it.
Disconnects this object.
Disconnects this object. You should discard this object after calling this method. No more queries will be accepted.
Checks whether we are still connected to the database.
Checks whether we are still connected to the database.
Sends a prepared statement to the database.
Sends a prepared statement to the database. Prepared statements are special statements that are pre-compiled by the database to run faster, they also allow you to avoid SQL injection attacks by not having to concatenate strings from possibly unsafe sources (like users) and sending them directy to the database.
When sending a prepared statement, you can insert ? signs in your statement and then provide values at the method call 'values' parameter, as in:
connection.sendPreparedStatement( "SELECT * FROM users WHERE users.login = ?", Array( "john-doe" ) )
As you are using the ? as the placeholder for the value, you don't have to perform any kind of manipulation to the value, just provide it as is and the database will clean it up. You must provide as many parameters as you have provided placeholders, so, if your query is as "INSERT INTO users (login,email) VALUES (?,?)" you have to provide an array with at least two values, as in:
Array("john-doe", "[email protected]")
You can still use this method if your statement doesn't take any parameters, the default is an empty collection.
Sends a statement to the database.
Sends a statement to the database. The statement can be anything your database can execute. Not all statements will return a collection of rows, so check the returned object if there are rows available.