static function router() { /* echo "Hola me llamo Pedro y estoy probando la function router"; Coder::code(self::$controller); Coder::code(self::$action); */ // if exists the controller then make and instance of controller $contr_call = self::$controller != "" ? self::$controller : 'Home'; $action_call = self::$action != "" ? self::$action : 'Home'; $filename = $contr_call . '.php'; $filecontroller = APP . 'controllers' . DS . ucfirst($filename); Coder::code(self::$controller); Coder::code(self::$action); if (is_readable($filecontroller)) { $cont = new $contr_call(); //check if action is an object method if (is_callable(array($cont, $action_call))) { call_user_func(array($cont, $action_call)); } else { // no function echo 'No action!'; } } else { // no function echo 'No controller!'; } }
static function init() { echo $_SERVER['REQUEST_URI']; Request::retrieve(); $controller = Request::getCont(); Coder::code($controller); //echo $controller."<br>"; $action = Request::getAct(); Coder::code($action); $params = Request::getparams(); Coder::code($params); }
static function init() { // recuperar la request echo $_SERVER['REQUEST_URI']; // extract all the components un URI Request::retrieve(); $controller = Request::getCont(); Coder::code($controller); $action = Request::getAct(); Coder::code($action); $params = Request::getParams(); Coder::codear($params); }
function create($dbname) { $dbhost = $this->conf->dbhost; $dbuser = $this->conf->dbuser; $dbpass = $this->conf->dbpass; $file = ROOT . 'install/app.sql'; //$this->import($dbhost,$dbuser,$dbpass,$dbname,$sql); try { $conn = new PDO($this->conf->driver . ':host=' . $dbhost, $dbuser, $dbpass); //$stmt = $conn->query("SHOW DATABASES"); //var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); $sql = 'CREATE Database ' . $dbname . ' CHARACTER SET utf8 COLLATE utf8_general_ci'; $stmt = $conn->query($sql); } catch (PDOException $e) { die('Could not connect: ' . $e->getMessage()); } //disconnect PDO connection $conn = null; //now connecting with new DSN $dsn = $this->conf->driver . ':host=' . $dbhost . ';dbname=' . $dbname; Coder::code($dsn); try { $conn = new PDO($dsn, $dbuser, $dbpass); } catch (PDOException $e) { die('Problem with connection' . $e->getMessage()); } echo 'Processing SQL script'; $query = file_get_contents($file); $sqlList = SQLParser::parse($query); Coder::code_var($sqlList); try { foreach ($sqlList as $sqlline) { // Perform the query $conn->query($sqlline); } } catch (PDOException $e) { echo $e->getMessage(); die; } echo 'Final'; return true; }
static function router() { //if exists controller the //make an instance of controller $contr_call = self::$controller != "" ? self::$controller : 'home'; $action_call = self::$action != "" ? self::$action : 'home'; $filename = $contr_call . 'php'; $filecontroller = APP . 'controllers' . DS . $filename; Coder::code($filecontroller); if (is_readable($filecontroller)) { //$cont=new action_controller (self::$params); //call_user_func(OBJ,function); $cont = new $contr_call(); if (is_callable(array($cont, $action_call))) { call_user_func(array($cont, $action_call)); } else { echo 'NO action!'; } } else { echo 'NO controller!'; } }