Ejemplo n.º 1
0
<?php

require_once '../php/DB_connection.php';
$dbh = DB_connection::getConnection();
$statement = $_GET['query'];
$sth = $dbh->prepare($statement);
$sth->execute();
if (strpos($statement, "DELETE") === false) {
    $data = $sth->fetchAll(PDO::FETCH_NUM);
    echo json_encode($data);
}
Ejemplo n.º 2
0
    $statement .= ")";
    $values = substr($values, 0, -1);
    $values .= ")";
    $statement .= " VALUES " . $values;
    // remove commentphrase // if you want to get the sql query in the output file as well
    echo '<br/>' . $statement;
    $dhb = DB_connection::getConnection();
    $sth = $dhb->prepare($statement);
    $sth->execute();
    // loeschen wenn "zu viele in db?
    $sth->closeCursor();
} else {
    // else query for GUI Dashboard
    if (isset($_POST['query']) && !empty($_POST['query'])) {
        echo $_POST['query'];
        $dhb = DB_connection::getConnection();
        $sth = $dhb->prepare($statement);
        $sth->execute();
        $data = $sth->fetchAll(PDO::FETCH_NUM);
        echo json_encode($data);
        $sth->closeCursor();
    }
}
// else{delete sth??
class DB_connection
{
    /**
     *
     * @var PDO
     */
    private static $con;