Back to all posts
Previous Post
MysqliPHPTechnology
Php Mysqli extension
SathishOctober 11, 2010

The MySql Improved Extension, a.k.a mysqli is faster more improved version of existing mysql. It is available in PHP 5 or later versions. The source code of mysqli is available at ext/mysqli.
Key Features of MySQLi
- Object-oriented interface
- Support for Prepared Statements
- Support for Multiple Statements
- Support for Transactions
- Enhanced debugging capabilities
- Embedded server support
Basic Connection Example
php
<?php
// Procedural style
$link = mysqli_connect("localhost", "user", "password", "database");
if (!$link) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
// Object-oriented style
$mysqli = new mysqli("localhost", "user", "password", "database");
if ($mysqli->connect_error) {
die("Connection failed: " . $mysqli->connect_error);
}
echo "Connected successfully";
?>Prepared Statement Example
php
<?php
$mysqli = new mysqli("localhost", "user", "password", "database");
$stmt = $mysqli->prepare("INSERT INTO users (name, email) VALUES (?, ?)");
$stmt->bind_param("ss", $name, $email);
$name = "John";
$email = "[email protected]";
$stmt->execute();
echo "New record created successfully";
$stmt->close();
$mysqli->close();
?>For further information on MySQLi, refer to the official PHP documentation.
Apache log4cxx framework – Part One
Next PostApache log4cxx framework – Example using Pthreads – Part Two
Comments
No comments yet. Be the first to comment.