Skip to content

Instantly share code, notes, and snippets.

@TheOpenDevProject
Created June 29, 2015 02:41
Show Gist options
  • Save TheOpenDevProject/a23869603dc0c0a3836c to your computer and use it in GitHub Desktop.
Save TheOpenDevProject/a23869603dc0c0a3836c to your computer and use it in GitHub Desktop.
DAL
<?php
require_once ($_SERVER['DOCUMENT_ROOT'] + 'path/to/idiorm.php');
class Config {
protected function __construct(){
ORM::configure('mysql:host=localhost;dbname=database');
ORM::configure('username','username');
ORM::configure('password','');
ORM::configure('return_result_sets', true);
}
};
class Manager extends Config{
public function CreateMachine($arg1,$arg2,$arg3){
$Writer = ORM::for_table('table_name')->create();
$Writer->MachineName = $arg1;
//...
//...
$Writer->save();
}
};
class EventLogger extends Config{
//NOTE $args... has a special meaning in PHP do not leave it like this. (It means its a variadic)
public function CreateSchedule($args...){
$Writer = ORM::for_table('table_name')->create();
$Writer->MachineName = $args;
//...
//...
$Writer->save();
}
public function GetAllSchedules(){
$scheduels = ORM::for_table('table_name')->find_many();
return $scheduels;
}
};
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment