Examples

Data Bases

All the following examples do not work on the "official server", for security reasons. Most of the scripts do not contain any security. Username and passwords for the production DB can not be presented for everybody to know. So connection is allways an error.
Download all these examples in one file: databases.zip

Sql queries

queries

PDO

View all supported DB for PDO (Source)
Test the connection to MySQL DB (disconection is also done) (Source)
Insertion a new article. (Source)
Select all records in the table "article". (Source)
Update a record in the article list. (Source)
Fetch the result of a select in different manner. (Source)
Fetch into an Object. (Source)
Prepared Statement using PDOStatement::fetchAll(). (Source)
Multiple prepared statements using PDOStatement::fetch() (Source)
Prepared statement (Source)
Transaction. (Source)
Get Last insertID. (Source)
Singleton Design Pattern for Connection. (Source)

mysql, the historic library (still in use in old projects)

Connect to a MySQL DB (Source)
Small script to be inserted in all our programs (Source)
Execute queries from an array (Source)
Count the number of rows in table article (Source)
Displays the result of a select query (Source)
Another way to display the result of a select query (Source)
Get the number of the created row (Source)
Get the name of all databases of the server (Source)

mysqli (the improved database)

The following examples do not work since our test server does not have a MySQL version that is newer than 4.1
Connect and view configuration of MySQLi (Source)
Visit the content of table 'article' (Source)