Пример #1
0
include_once '../includes/tipoRespuesta.php';
include_once '../includes/Answer.php';
//include_once ('../PDO/NewModel.php');
$tipo = new TipoRespuesta();
$respuesta = new Answer();
if (isset($_SESSION['name']) and $_SESSION['id'] == '10207674962976867') {
    if (isset($_GET['id_type'])) {
        $id_type = $_GET['id_type'];
        $id_answer = $_GET['id_answer'];
        //echo "<script type=\"text/javascript\">
        //   alert('Se ha borrado correctamente la noticia');
        //history.go(-2);
        //</script>";
        //exit;
        $query = $pdo->prepare('DELETE FROM TipoRespuesta WHERE id_type = ?');
        $query = bindValue(1, $id_type);
        $query->execute();
        echo "<script type=\"text/javascript\">\n           alert('Se ha borrado correctamente el tipo');\n           history.go(-2);\n        </script>";
        exit;
    }
    $tipos = $tipo->fetch_all();
    $respuestas = $respuesta->fetch_all();
    ?>

    <html xmlns="http://www.w3.org/1999/html">
    <head>
        <title>Eliminar Tipo - Version editable</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <link href="../../Card-2/card-2.css" type="text/css" rel="stylesheet">
        <!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.0/css/materialize.min.css">-->
        <link href="../css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<?php

//get category data
$name = filter_input(INPUT_POST, 'name');
//make sure that $name is valid
if ($name == null) {
    $error = "Invalid name";
    include 'error.php';
} else {
    require_once 'database.php';
}
//add product to database
$query = 'INSERT INTO categories(categoryName) VALUES(:category_name)';
$statement = $db->prepare($query);
$statement = bindValue(':category_name', $name);
$statement->execute();
$statement->closeCursor();
//display Category List
include 'category_list.php';
/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
Пример #3
0
$username = $config['user'];
$password = $config['password'];
$host = $config['host'];
$port = $config['port'];
$dbname = $config['dbname'];
$connection_string = "(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = " . $host . ")(PORT = " . $port . ")) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = " . $dbname . ")))";
$connection = oci_connect($username, $password, $connection_string);
log_if_error($connection);
$statement = oci_parse($connection, "INSERT INTO PARAMETRO(CHAVE, VALOR, DATA_CRIACAO) VALUES(:param1, :param2, TO_DATE(:param3, 'YYYY-MM-DD HH24:MI:SS'))");
log_if_error($statement);
$chave = 'chave_sample';
$valor = 'valor_sample';
$data = new \DateTime();
$data = $data->format('Y-m-d H:i:s');
bindValue($statement, ':param1', $chave);
bindValue($statement, ':param2', $valor);
// Using oci_bind_by_name after using bindValue still reproduces the same behaviour
oci_bind_by_name($statement, ':param3', $data);
/**
 * Inserted values will be | $data | $data | $data |
 * Instead of | $chave | $valor | $data |
 */
$result = oci_execute($statement);
log_if_error($result);
/**
 * If $value is set as reference it will work fine
 * It also works if you copy $value to a variable outside function scope.
 */
function bindValue($statement, $name, $value)
{
    /** Local variable as reference to oci_bind_by_name? */
Пример #4
0
$password = $config['password'];
$host = $config['host'];
$port = $config['port'];
$dbname = $config['dbname'];
$connection_string = "(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = " . $host . ")(PORT = " . $port . ")) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = " . $dbname . ")))";
$connection = oci_connect($username, $password, $connection_string);
log_if_error($connection);
$statement = oci_parse($connection, "INSERT INTO PARAMETRO(CHAVE, VALOR, DATA_CRIACAO) VALUES(:param1, :param2, TO_DATE(:param3, 'YYYY-MM-DD HH24:MI:SS'))");
log_if_error($statement);
$chave = 'chave_sample';
$valor = 'valor_sample';
$data = new \DateTime();
$data = $data->format('Y-m-d H:i:s');
bindValue($statement, ':param1', $chave);
bindValue($statement, ':param2', $valor);
bindValue($statement, ':param3', $data);
/**
 * Inserted values will be | $data | $data | $data |
 * Instead of | $chave | $valor | $data |
 */
$result = oci_execute($statement);
log_if_error($result);
/**
 * If $value is set as reference it will work fine
 * It also works if you copy $value to a variable outside function scope.
 */
function bindValue($statement, $name, $value)
{
    /** Local variable as reference to oci_bind_by_name? */
    return oci_bind_by_name($statement, $name, $value);
}