39 lines
No EOL
1.1 KiB
PHP
39 lines
No EOL
1.1 KiB
PHP
<?php
|
|
namespace AroMVC;
|
|
use AroMVC\Core\Configuration;
|
|
use AroMVC\Core\Database;
|
|
use AroMVC\Core\Selectable;
|
|
use AroMVC\Models\Company;
|
|
|
|
spl_autoload_register(function($class) {
|
|
$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")
|
|
require_once "AroMVC". DIRECTORY_SEPARATOR . $parts[2] .".php";
|
|
else if(in_array($parts[1], ["Controllers", "Models", "ViewModels"]))
|
|
require_once $parts[1]. DIRECTORY_SEPARATOR. $parts[2] .".php";
|
|
else
|
|
die("Autoloader failed: malformed class name $class");
|
|
}
|
|
});
|
|
|
|
// TODO write error handler
|
|
|
|
Configuration::initialize(file_get_contents("conf.ini"));
|
|
Database::initialize();
|
|
|
|
$tmp = new Selectable("*");
|
|
|
|
$tmp->from("Companies")
|
|
->where("`name` = :name OR `id` = :cid")
|
|
->params(["name" => "winco", "cid" => 20])
|
|
->join("LEFT JOIN", "Invoices")
|
|
->using("id")
|
|
->execute()
|
|
->asModels(new Company); |