Beispiel #1
0
function checkConnection($conn)
{
    if ($conn->connect_error) {
        debugMessages("Connection failed: " . $conn->connect_error, "debugSQL");
        return false;
    } else {
        return true;
    }
}
Beispiel #2
0
function createTable($name, $cols, $colTypes, $conn)
{
    if (count($cols) != count($colTypes)) {
        if ($GLOBALS["debugSQL"]) {
            echo "Incorrect sql query parameters.";
        }
        return NULL;
    }
    $sqlQuery = "CREATE TABLE " . $name . " (`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ";
    for ($i = 0; $i < count($cols); $i++) {
        $sqlQuery .= ", `" . $cols[$i] . "` " . $colTypes[$i];
    }
    $sqlQuery .= ") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
    $conn->real_escape_string($sqlQuery);
    debugMessages($sqlQuery, "debugSQL");
    $res = $conn->query($sqlQuery);
    if (!empty(mysqli_error($conn))) {
        debugMessages(mysqli_error($conn), "debugSQL");
    }
    return $res;
}