Exemplo n.º 1
0
<?php 
//check auth
include_once "../functions/client.php";
include_once "../functions/utils.php";
$client = new client();
if (!$client->logged_in()) {
    die("false");
}
//check POST
$table_name = null;
$fields_count = 0;
$foreign_keys_count = 0;
if ($_POST) {
    $table_name = totally_escape($_POST["table_name"]);
    $fields_count = $_POST["fields_count"];
    $foreign_keys_count = $_POST["foreign_keys_count"];
}
if ($table_name == null) {
    die("false: bad table_name");
}
//prepare statement
$types_arr = sql_types_array();
//TODO: test table_name is one word or something
$has_precision = array("NUMBER", "FLOAT", "INTERVAL YEAR TO MONTH", "INTERVAL DAY TO SECOND");
$has_length = array("NUMBER" => 38, "VARCHAR2" => 4000, "CHAR" => 2000, "TIMESTAMP" => -1, "INTERVAL DAY TO SECOND" => -1, "TIMESTAMP WITH TIME ZONE" => -1, "TIMESTAMP WITH LOCAL TIME ZONE" => -1, "RAW" => -1, "NCHAR" => 2000, "NVARCHAR2" => 4000);
//lol that's where we use transactions:
//COMMIT; //ends any other transactions
//SET TRANSACTION NAME 'sal_update'; //start transaction
//...
//ROLLBACK; //if fail
//COMMIT; //if success