50 lines
No EOL
1.4 KiB
PHP
50 lines
No EOL
1.4 KiB
PHP
<?php
|
|
namespace AroMVC;
|
|
include "AroMVC/Configuration/Configuration.php";
|
|
include "AroMVC/Configuration/ConfigSection.php";
|
|
use AroMVC\Configuration\Configuration as conf;
|
|
use AroMVC\Database\Database as db;
|
|
use AroMVC\Database\Selectable;
|
|
use Fire\Models\Company;
|
|
|
|
conf::initialize(file_get_contents("conf.ini"));
|
|
spl_autoload_register(function($class) {
|
|
$userns = conf::section("Project")->value("namespace");
|
|
|
|
$class = str_replace("_", "\\", $class);
|
|
$class = ltrim($class, '\\');
|
|
|
|
$parts = explode("\\", $class);
|
|
if($parts[0] == "AroMVC") {
|
|
if(count($parts) < 3)
|
|
die("Autoloader failed: malformed class name $class");
|
|
|
|
if($parts[1] == "Core")
|
|
return;
|
|
|
|
require_once "AroMVC" . DIRECTORY_SEPARATOR . $parts[1] . DIRECTORY_SEPARATOR . $parts[2] . ".php";
|
|
} else if($parts[0] == $userns) {
|
|
if(in_array($parts[1], ["Controllers", "Models", "ViewModels"]))
|
|
require_once $parts[1] . DIRECTORY_SEPARATOR . $parts[2] .".php";
|
|
}
|
|
});
|
|
db::initialize();
|
|
|
|
// TODO write error handler
|
|
|
|
$company = Company::withId(1);
|
|
|
|
var_dump(
|
|
/*$tmp->from("Companies")
|
|
->where("`name` = :name OR `id` = :cid")
|
|
->params(["name" => "winco", "cid" => 20])
|
|
->join("LEFT JOIN", "Invoices")
|
|
->using("id")
|
|
->execute()
|
|
->asModels(new Company)*/
|
|
$company
|
|
);
|
|
|
|
echo $company->name;
|
|
|
|
var_dump($company->states->asModels()); |