Important
New database features are no longer connected to engine versions; features are now enabled independently during scheduled update windows, and “major” and “minor” releases no longer exist in Helios. Please visit the release notes to view the latest features available in your database clusters.
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: