Von Mysqli zurück zu mysql

mrepox

Erfahrenes Mitglied
:p Hallo ,
ich habe ein Shop Script, welches auf msqli basiert.

Da mein Hoster von mysqli noch nichts wissen will, muss ich das Script umschreiben.

Hier ist mal ein Beispiel: Kann mir da jemand Hilfestellung geben wie ich das anstelle?


PHP:
<?php

function db_connect()
{
    $result = new mysqli('localhost', 'book_sc', 'password', 'book_sc');
    if (!$result)
        return FALSE;
    $result->autocommit(TRUE);
    return $result;
}

function db_result_to_array($result)
{
    $res_array = array();

    for ($count = 0; $row = $result->fetch_assoc(); $count++)
        $res_array[$count] = $row;

    return $res_array;
}

?>


Und hier noch ein Auszug:

PHP:
$query = "insert into orders values
              ('', $customerid, " . $_SESSION['total_price'] . ", '$date', 'PARTIAL', '$ship_name',
               '$ship_address','$ship_city','$ship_state','$ship_zip',
               '$ship_country')";

    $result = $conn->query($query);
    if (!$result)
        return FALSE;

    $query = "select orderid from orders where
               customerid = $customerid and
               amount > " . $_SESSION['total_price'] . "-.001 and
               amount < " . $_SESSION['total_price'] . "+.001 and
               date = '$date' and
               order_status = 'PARTIAL' and
               ship_name = '$ship_name' and
               ship_address = '$ship_address' and
               ship_city = '$ship_city' and
               ship_state = '$ship_state' and
               ship_zip = '$ship_zip' and
               ship_country = '$ship_country'";
    $result = $conn->query($query);
    if ($result->num_rows > 0) {
        $order = $result->fetch_object();
        $orderid = $order->orderid;
    } else
        return FALSE;

    //  Artikel einfügen
    foreach($_SESSION['cart'] as $isbn => $quantity) {
        $detail = get_book_details($isbn);
        $query = "delete from order_items where
                  orderid = '$orderid' and isbn =  '$isbn'";
        $result = $conn->query($query);
        $query = "insert into order_items values
                  ('$orderid', '$isbn', " . $detail['price'] . ", $quantity)";
        $result = $conn->query($query);
        if (!$result)
            return FALSE;
    }

    // Transaktion beenden
    $conn->commit();
    $conn->autocommit(TRUE);

    return $orderid;
}
?>

Mir ist msqli gänzlich unbekannt, deshalb weiss ich gar nicht wie und wo ich anfangen soll.


Danke für eventuelle Hilfe....
 
Zurück