I am trying to recreate Laravel ORM (Eloquent).
In Laravel we can do something like:
Model::where("condition1")->where("condition2")->get();
So far my attempts to recreate this lead me to write this code:
class DB {
static $condition ;
public static function chidlClassName() {
return get_called_class();
}
static function where( $cond ) {
self::$condition[] = $cond;
return new DB();
}
public function where( $cond ){
self::$condition[] = $cond ;
return $this;
}
function get(){
$cond = implode(' AND ' ,self::$condition);
}
}
class Modle extends DB {}
But it wont work because both where functions have the same name...
How does the Laravel do it?