How to access the database

Last modified by Stéphane Laurière on 2014/04/08 19:27

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>";
}
?>
Tags:
Created by Stéphane Laurière on 2014/04/08 18:08

Partners

Orange

VOICES

EU - FP7

OW2

© Emerginov
Site maintained by OW2