-
Notifications
You must be signed in to change notification settings - Fork 0
berry.mysql
Every modern web application interacts with a database. PHP-Berry makes interacting with MySQL and MariaDB databases extremely simple and fast using raw SQL and prepare statements. A prepared statement or a parameterized statement is used to execute the same statement repeatedly with high efficiency and protect against SQL injections.
The berry.mysql package includes all necessary tools to read, write and update data to a MySQL Server.
PHP-Berry does not need any special configuration to connect to a database. All you need to be able to exchange data with a database is to initialize a connection. The following example shows how you can initialize a MySQL/MariaDB connection
require_once(__DIR__ . "/berry/mysql.php"); // Include php-berry mysql package
// Establish a connection with MySQL/MariaDB server
$connection = new MySQLConnection('localhost', "database_name", "username", "password", "utf8");
At this point PHP-Berry interacts with MySQL and MariaDB databases using raw SQL and prepare statements. Prepared statements should be used in cases where the need for performance is critical, as they are the fastest and safest way for a PHP application to communicate with a MySQL database.