Exemple #1
0
 public function __construct()
 {
     $this->db_conn_ = Connection::dbConn();
     $class_properties = get_class_vars(get_class($this));
     foreach ($class_properties as $field => $value) {
         /* Jumping db_conn_, because they are not a field property
            defined in a model class */
         if (substr($field, -1) == '_') {
             continue;
         }
         $field_type = $value[0];
         switch ($field_type) {
             case 'CharField':
                 $this->{$field} = new CharField($value[1]);
                 break;
         }
     }
 }
Exemple #2
0
function db_connect()
{
    $pdo = new PDO('mysql:host=localhost;dbname=' . DB, USER_DB, PASSWORD_DB, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
    Conn::dbConn($pdo);
}
Exemple #3
0
<?php

ini_set("display_errors", 1);
ini_set("display_startup_erros", 1);
error_reporting(E_ALL);
require_once 'vendor/autoload.php';
require_once 'settings.php';
use DJORM\Connection as Conn;
use MODELS\PersonModel;
//PDO Conn
$pdo = new PDO('mysql:host=localhost;dbname=' . DB, USER_DB, PASSWORD_DB, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
Conn::dbConn($pdo);
$teste = new PersonModel();
echo 'Testando....';
$teste->save();
echo '<br><br> Funcionou: ' . $teste->name;