示例#1
0
 public function __construct()
 {
     $this->core = Core::getInstance();
     //getting instance from core
     $this->db = $this->core->connection;
     //setting models $db to connection with database and use NOTORM
 }
示例#2
0
 function __construct()
 {
     $this->core = Core::getInstance();
     //$this->core->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 }
 function __construct($userdb)
 {
     $this->core = Core::getInstanceWithUserDB($userdb);
 }
示例#4
0
 function __construct()
 {
     $this->core = Core::getInstance();
 }
示例#5
0
    }
});
$app->get('/colector/archivos/descargar/:nombre', function ($nombre) use($app) {
    $file = MEDIA_DIR . DS . "{$nombre}";
    //file location
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename="' . basename($file) . '"');
    header('Content-Length: ' . filesize($file));
    readfile($file);
});
$app->get('/colector/test', function () use($app) {
    $coredb = Core::getInstance();
    $query = "SELECT * from archivos ORDER BY id DESC LIMIT 1";
    $r = array();
    $stmt = $coredb->dbh->prepare($query);
    $r = $stmt->execute() ? $stmt->fetchAll(PDO::FETCH_ASSOC) : 0;
    if (count($r) > 0) {
        header("Content-Type: text/plain");
        echo nl2br(file_get_contents($r[0]['ruta']));
    }
});
$app->get('/colector/db', function () use($app) {
    $coredb = Core::getInstance();
    try {
        // DROP TABLE IF EXISTS archivos ;
        $query = "\n\t\t\t\t\tCREATE TABLE IF NOT EXISTS archivos(\n\t\t\t\t\t\t\tid INTEGER PRIMARY KEY AUTOINCREMENT,\n\t\t\t\t\t\t\tnombre TEXT,\n\t\t\t\t\t\t\thash TEXT,\n\t\t\t\t\t\t\truta TEXT,\n\t\t\t\t\t\t\tcreated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n\t\t\t\t\t\t\tupdated_at DATETIME DEFAULT CURRENT_TIMESTAMP\n\t\t\t\t\t);\n\t\t\t";
        $stmt = $coredb->dbh->exec($query);
    } catch (PDOException $e) {
        echo $e->getMessage();
    }
});