This repository has been archived on 2024-10-04. You can view files and clone it, but cannot push or open issues or pull requests.
AroMVC/index.php

42 lines
1.2 KiB
PHP
Raw Normal View History

2017-02-24 16:39:37 +00:00
<?php
namespace AroMVC;
2017-03-01 21:58:13 +00:00
use AroMVC\Configuration\Configuration as conf;
use AroMVC\Database\Database as db;
use AroMVC\Database\Selectable;
2017-02-24 16:39:37 +00:00
use AroMVC\Models\Company;
2017-03-01 21:58:13 +00:00
conf::initialize(file_get_contents("conf.ini"));
db::initialize();
2017-02-24 22:01:32 +00:00
spl_autoload_register(function($class) {
2017-03-01 21:58:13 +00:00
$userns = Configuration::section("Project")->value("namespace");
2017-02-24 22:01:32 +00:00
$class = str_replace("_", "\\", $class);
$class = ltrim($class, '\\');
$parts = explode("\\", $class);
if($parts[0] == "AroMVC") {
2017-03-01 21:58:13 +00:00
if(count($parts) < 2)
2017-02-24 22:01:32 +00:00
die("Autoloader failed: malformed class name $class");
if($parts[1] == "Core")
require_once "AroMVC". DIRECTORY_SEPARATOR . $parts[2] .".php";
else
die("Autoloader failed: malformed class name $class");
2017-03-01 21:58:13 +00:00
} else if($parts[0] == $userns) {
if(in_array($parts[1], ["Controllers", "Models", "ViewModels"]))
require_once $parts[1]. DIRECTORY_SEPARATOR. $parts[2] .".php";
2017-02-24 22:01:32 +00:00
}
});
2017-02-28 21:46:54 +00:00
// TODO write error handler
$tmp = new Selectable("*");
2017-02-24 16:39:37 +00:00
$tmp->from("Companies")
2017-02-28 21:46:54 +00:00
->where("`name` = :name OR `id` = :cid")
->params(["name" => "winco", "cid" => 20])
->join("LEFT JOIN", "Invoices")
->using("id")
2017-02-24 22:01:32 +00:00
->execute()
2017-02-28 21:46:54 +00:00
->asModels(new Company);