Example #1
0
 private static function setup_database()
 {
     if (!self::$_db_loaded) {
         $host = CMS\Libraries\Config::get('db_host');
         $database = CMS\Libraries\Config::get('db_database');
         $username = CMS\Libraries\Config::get('db_username');
         $password = CMS\Libraries\Config::get('db_password');
         CMS\Libraries\ORM::configure("mysql:host={$host};dbname={$database}");
         CMS\Libraries\ORM::configure('username', $username);
         CMS\Libraries\ORM::configure('password', $password);
         self::$_db_loaded = true;
         // At this point we are not in love with our ORM so use the Cloudmanic database
         // library which we included via composer. (TODO: We should get rid of the ORM above at
         // some point).
         Cloudmanic\Database\DB::connection($host, $username, $password, $database);
     }
 }
Example #2
0
<?php

ini_set('display_errors', 1);
error_reporting(E_ALL);
require 'vendor/autoload.php';
// Static version
Cloudmanic\Database\DB::connection('HOSTNAME HERE', 'USERNAME HERE', 'PASS HERE', 'DATABASE HERE');
Cloudmanic\Database\DB::set_table('Users');
$query = array('UsersFirstName' => 'Lady', 'UsersLastName' => 'Gaga');
$id = Cloudmanic\Database\DB::insert($query);
echo '<pre>' . print_r($id, TRUE) . '</pre>';
// Instance version
$db = new Cloudmanic\Database\Instance('HOSTNAME HERE', 'USERNAME HERE', 'PASS HERE', 'DATABASE HERE');
$db->set_table('Users');
$query = array('UsersFirstName' => 'Katie', 'UsersLastName' => 'Perry');
$id = $db->insert($query);
echo '<pre>' . print_r($id, TRUE) . '</pre>';