Important
The SingleStore 9.1 release candidate (RC) is available now. It will be promoted to general availability (GA) soon and at that time it will be renamed to SingleStore 10.
In the interim, SingleStore 9.1 RC can be used to preview, evaluate, and provide feedback on the new and upcoming features in SingleStore 10, while SingleStore 9.0 is recommended for production workloads.
Connect with PHP
You can connect to SingleStore via PHP using PHP Data Objects (PDO) or MySQLi.
To connect using PDO, you need to create a DSN from the host, port, and database name, and then pass the DSN to the PDO constructor along with the database username and password.
Note
To read the connection information from the environment, use the $_ notation.
<?php$host = $_SERVER['HOSTNAME'];$port = $_SERVER['PORT'];$user = $_SERVER['USERNAME'];$password = $_SERVER['PASSWORD'];$db = $_SERVER['DB_NAME'];$charset = 'utf8';$dsn = "mysql:host={$host};port={$port};dbname={$db};charset={$charset}";$pdo = new PDO($dsn, $user, $password);?>
To connect using MySQLi, pass the host, username, password, database name, and port to the mysqli constructor.
$link = new mysqli($_SERVER['HOSTNAME'], $_SERVER['USERNAME'], $_SERVER['PASSWORD'], $_SERVER['DB_NAME'], $_SERVER['PORT']);
Last modified: