Skip to content

berry.mysql.MySQLConnection

Nikos Siatras edited this page Sep 30, 2022 · 14 revisions

Definition

MySQLConnection class represents a connection to a MySQL Server database.

 public function __construct($serverIP, $database, $user, $password, $charset = "")

MySQLConnection Class Methods

Method Description
MySQLConnection.EscapeString(String $string):String Escapes special characters in a string for use in an SQL statement, taking into account the current charset of the connection
MySQLConnection.Close() Closes the MySQLConnection

MySQLConnection Examples

The following simple examples will try to explain the use of Berry's MySQLConnection object

Establish a MySQL Connection

The following example explains how to establish a MySQLConnection

require_once(__DIR__ . "/berry/mysql.php"); // Include php-berry mysql package

// Establish a connection with MySQL server
$connection = new MySQLConnection('localhost', "database_name", "username", "password", 'utf8');
$connection->Close(); // Closes the connection
Clone this wiki locally