2017-02-24 10:39:37 -06:00
< ? php
namespace AroMVC ;
2017-03-02 16:02:38 -06:00
include " AroMVC/Configuration/Configuration.php " ;
include " AroMVC/Configuration/ConfigSection.php " ;
2017-03-01 15:58:13 -06:00
use AroMVC\Configuration\Configuration as conf ;
use AroMVC\Database\Database as db ;
use AroMVC\Database\Selectable ;
2017-03-02 16:02:38 -06:00
use Fire\Models\Company ;
2017-02-24 10:39:37 -06:00
2017-03-01 15:58:13 -06:00
conf :: initialize ( file_get_contents ( " conf.ini " ));
2017-02-24 16:01:32 -06:00
spl_autoload_register ( function ( $class ) {
2017-03-02 16:02:38 -06:00
$userns = conf :: section ( " Project " ) -> value ( " namespace " );
2017-03-01 15:58:13 -06:00
2017-02-24 16:01:32 -06:00
$class = str_replace ( " _ " , " \\ " , $class );
$class = ltrim ( $class , '\\' );
$parts = explode ( " \\ " , $class );
if ( $parts [ 0 ] == " AroMVC " ) {
2017-03-02 16:02:38 -06:00
if ( count ( $parts ) < 3 )
2017-02-24 16:01:32 -06:00
die ( " Autoloader failed: malformed class name $class " );
if ( $parts [ 1 ] == " Core " )
2017-03-02 16:02:38 -06:00
return ;
require_once " AroMVC " . DIRECTORY_SEPARATOR . $parts [ 1 ] . DIRECTORY_SEPARATOR . $parts [ 2 ] . " .php " ;
2017-03-01 15:58:13 -06:00
} else if ( $parts [ 0 ] == $userns ) {
if ( in_array ( $parts [ 1 ], [ " Controllers " , " Models " , " ViewModels " ]))
2017-03-02 16:02:38 -06:00
require_once $parts [ 1 ] . DIRECTORY_SEPARATOR . $parts [ 2 ] . " .php " ;
2017-02-24 16:01:32 -06:00
}
});
2017-03-02 16:02:38 -06:00
db :: initialize ();
2017-02-24 16:01:32 -06:00
2017-02-28 15:46:54 -06:00
// TODO write error handler
2017-03-02 16:02:38 -06:00
$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 ;
2017-02-24 10:39:37 -06:00
2017-03-02 16:02:38 -06:00
var_dump ( $company -> states -> asModels ());