How to access the database


We suppose you asked for a database when you created your project.

To manage your database, you can browse PHPMyAdmin at http://phpmyadmin.<your_emerginov>

Let us assume you created a table users in your database.

Login and passwords can be found in your project passwords.php file

Sample file to access Database:

<?php
// Load required configuration & Emerginov Class
require_once("passwords.php");
require_once("Emerginov.php");

// Connection to MySQL using PDO (PHP Database Object)
$dns = "mysql:host=$mysql_db_server;dbname=$mysql_db_name";
$connection = new PDO( $dns, $mysql_db_login, $mysql_db_password );
    
// Now do a simple SELECT request on the table users
$select = $connection->query("SELECT * FROM users");
    
// Use object
$select->setFetchMode(PDO::FETCH_OBJ);
    
// Print the result
while ($user = $select->fetch()){
    echo "<p>User id #".$user->id." is ".$user->name."</p>";
}
?>