本文整理汇总了PHP中db2_execute函数的典型用法代码示例。如果您正苦于以下问题:PHP db2_execute函数的具体用法?PHP db2_execute怎么用?PHP db2_execute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db2_execute函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadBioInfo
function uploadBioInfo()
{
if (!isset($_SESSION['current_user_name']) && !isset($_COOKIE[$cookie_name])) {
header('Location: ../login.php');
exit;
} else {
//print_r($_POST);
if (isset($_POST)) {
$AnimalID = $_POST['AnimalID'];
$species = $_POST['species'];
$Phylum = $_POST['Phylum'];
$Class = $_POST['Class'];
$Order = $_POST['Order'];
$Family = $_POST['Family'];
$Genus = $_POST['Genus'];
$warmblooded = $_POST['warmblooded'];
$Cover = $_POST['Cover'];
$Reproduction = $_POST['Reproduction'];
$Habitat = $_POST['Habitat'];
$food = $_POST['food'];
$BodyTemp = $_POST['BodyTemp'];
$EnviTemp = $_POST['EnviTemp'];
$LifeSpan = $_POST['LifeSpan'];
// an array that want to insert this can be multiple array at the time.
$data = array($AnimalID, $species, $Phylum, $Class, $Order, $Family, $Genus, $warmblooded, $Cover, $Reproduction, $Habitat, $food, $BodyTemp, $EnviTemp, $LifeSpan);
// print var_dump to display an array of variable data with type that prepare for query.
//echo var_dump($data) ."<br>";
}
require_once '/var/www/html/app/model/connect.php';
$conn = dbConnect();
if ($conn) {
// DEFAULT if you set generated as identify with specifier this will auto increament for integer.
$sql = 'INSERT INTO EMM_ZOO.BIOINFO (SPECIESID,SPECIESNAME, PHYLUM, CLASS, ORDER, FAMILY, GENUS, WARMBLOODED, BODYCOVER, REPRODUCTION, HABITAT, COMMONFOOD, BODYTEMP, ENVITEMPRANGE, LIFESPAN) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);';
//echo $sql;
// prepare statement using connection and sql
$stmt = db2_prepare($conn, $sql);
// If statement is valid execute it to db2
if ($stmt) {
//echo "SQL is valid<br>";
$result = db2_execute($stmt, $data);
if ($result) {
$resultMessage = "Successfully added to Biological information";
echo "Successfully added";
header('Location: BioInfo.php');
exit;
} else {
$resultMessage = "Failed to query into database";
}
} else {
// If statement is error why see the code
die('Critical error:' . db2_stmt_error());
}
db2_free_stmt($stmt);
db2_close($conn);
} else {
echo db2_conn_errormsg();
}
}
}
示例2: insertSaniEmp
function insertSaniEmp()
{
//print_r($_POST);
if (isset($_POST)) {
$empid = $_POST['empid'];
$zoneid = $_POST['zoneid'];
$jobid = '17';
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$birthdate = $_POST['birthdate'];
$sex = $_POST['sex'];
$nationality = $_POST['nationality'];
$hiredate = $_POST['hiredate'];
$address = $_POST['address'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$salary = $_POST['salary'];
$bonus = $_POST['bonus'];
// an array that want to insert this can be multiple array at the time.
$data = array($empid, $zoneid, $jobid, $firstname, $lastname, $birthdate, $sex, $nationality, $hiredate, $address, $email, $phone, $salary, $bonus);
// 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) {
$sql = 'INSERT INTO EMM_ZOO.EMPLOYEE (EMPID, ZONEID, JOBID, FIRSTNAME, LASTNAME, BIRTHDATE, SEX, NATIONALITY, HIREDATE, ADDRESS, EMAIL, PHONE, SALARY, BONUS) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?);';
//$sql2 = 'INSERT INTO EMM_ZOO.EMP_SANI (EMPID) VALUES (?);';
//echo $sql;
// prepare statement using connection and sql
$stmt = db2_prepare($conn, $sql);
// If statement is valid execute it to db2
if ($stmt) {
//echo "SQL is valid<br>";
$result = db2_execute($stmt, $data);
if ($result) {
$resultMessage = "Successfully added to sanitation employee";
//echo "Successfully added";
echo "<script>";
echo "alert('Added successfully')";
echo "</script>";
header('Location: addEmpHome.php');
exit;
} else {
$resultMessage = "Failed to query into database";
echo "<script>";
echo "alert('Failed to query into database')";
echo "</script>";
}
} else {
// If statement is error why see the code
die('Critical error:' . db2_stmt_error());
}
db2_free_stmt($stmt);
db2_close($conn);
} else {
echo db2_conn_errormsg();
}
}
示例3: query
public static function query($conn, $sql)
{
if ($conn && strlen($sql) > 0) {
$stmt = db2_prepare($conn, $sql);
if (db2_execute($stmt)) {
return $stmt;
}
}
return false;
}
示例4: insertBuilding
function insertBuilding()
{
if ($_POST['form_token'] != $_SESSION['form_token']) {
header('Location:index.php');
} else {
//print_r($_POST);
if (isset($_POST)) {
$emm = $_POST['BEmp'];
$zone = $_POST['BZone'];
$build = $_POST['Building'];
$floor = $_POST['floor'];
$room = $_POST['room'];
// an array that want to insert this can be multiple array at the time.
$data = array($build, $floor, $room);
// 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.
$sql = 'INSERT INTO EMM_ZOO.MAINTAINBUILDING (MAINTEGERAINID, BUILDINGNAME, FLOORLEVEL, ROOM) VALUES (DEFAULT,?,?,?);';
//echo $sql;
// prepare statement using connection and sql
$stmt = db2_prepare($conn, $sql);
// If statement is valid execute it to db2
if ($stmt) {
//echo "SQL is valid<br>";
$result = db2_execute($stmt, $data);
if ($result) {
$resultMessage = "Successfully added";
//echo "Successfully added";
echo "<script>";
echo "alert('Successfully')";
echo "</script>";
header('Location: index.php');
exit;
} else {
echo "<script>";
echo "alert('Failed')";
echo "</script>";
$resultMessage = "Failed to query into database";
}
} else {
// If statement is error why see the code
die('Critical error:' . db2_stmt_error());
}
db2_free_stmt($stmt);
db2_close($conn);
} else {
echo db2_conn_errormsg();
}
}
}
示例5: __construct
/**
* This function initializes the class.
*
* @access public
* @override
* @param DB_Connection_Driver $connection the connection to be used
* @param string $sql the SQL statement to be queried
* @param integer $mode the execution mode to be used
* @throws Throwable_SQL_Exception indicates that the query failed
*
* @see http://www.php.net/manual/en/function.db2-prepare.php
* @see http://www.php.net/manual/en/function.db2-execute.php
* @see http://www.php.net/manual/en/function.db2-stmt-error.php
*/
public function __construct(DB_Connection_Driver $connection, $sql, $mode = NULL)
{
$resource = $connection->get_resource();
$command = @db2_prepare($resource, $sql);
if ($command === FALSE) {
throw new Throwable_SQL_Exception('Message: Failed to query SQL statement. Reason: :reason', array(':reason' => @db2_conn_errormsg($resource)));
}
if (!@db2_execute($command)) {
throw new Throwable_SQL_Exception('Message: Failed to query SQL statement. Reason: :reason', array(':reason' => @db2_stmt_errormsg($command)));
}
$this->command = $command;
$this->record = FALSE;
}
示例6: insertUselog
function insertUselog()
{
//print_r($_POST);
if (isset($_POST)) {
$equipid = $_POST['equipid'];
$equipname = $_POST['equipname'];
$empid = $_POST['empid'];
$zoneid = $_POST['zoneid'];
$borrowdate = $_POST['borrowdate'];
$returndate = $_POST['returndate'];
// an array that want to insert this can be multiple array at the time.
$data = array($equipid, $equipname, $empid, $zoneid);
// 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) {
$sql = 'INSERT INTO EMM_ZOO.SANI_EQUIPUSELOG (EQUIPID, EMPID, WORKZONEID, BORROWDATE, RETURNDATE) VALUES (?,?,?,?,?);';
//$sql2 = 'INSERT INTO EMM_ZOO.EMP_SANI (EMPID) VALUES (?);';
//echo $sql;
// prepare statement using connection and sql
$stmt = db2_prepare($conn, $sql);
// If statement is valid execute it to db2
if ($stmt) {
//echo "SQL is valid<br>";
$result = db2_execute($stmt, $data);
if ($result) {
$resultMessage = "Successfully added to Equipment use log";
//echo "Successfully added";
echo "<script>";
echo "alert('Added successfully')";
echo "</script>";
header('Location: addUselogHome.php');
exit;
} else {
$resultMessage = "Failed to query into database";
echo "<script>";
echo "alert('Failed to query into database')";
echo "</script>";
}
} else {
// If statement is error why see the code
die('Critical error:' . db2_stmt_error());
}
db2_free_stmt($stmt);
db2_close($conn);
} else {
echo db2_conn_errormsg();
}
}
示例7: insertEmpAtt
function insertEmpAtt()
{
//print_r($_POST);
if (isset($_POST)) {
$attno = $_POST['attno'];
$dates = $_POST['dates'];
$empid = $_POST['empid'];
$workzoneid = $_POST['workzoneid'];
$dutyid = $_POST['carplate'];
$starttime = $_POST['starttime'];
$endtime = $_POST['endtime'];
// an array that want to insert this can be multiple array at the time.
$data = array($attno, $dates, $empid, $workzoneid, $dutyid, $starttime, $endtime);
// 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) {
$sql = 'INSERT INTO EMM_ZOO.SANIEMP_ATTEND (ATTENDNO, DATES, EMPID, WORKZONEID, DUTYID, STARTTIME, ENDTIME) VALUES (?,?,?,?,?,?,?);';
// prepare statement using connection and sql
$stmt = db2_prepare($conn, $sql);
// If statement is valid execute it to db2
if ($stmt) {
//echo "SQL is valid<br>";
$result = db2_execute($stmt, $data);
if ($result) {
$resultMessage = "Successfully added to sanitation car";
//echo "Successfully added";
echo "<script>";
echo "alert('Added successfully')";
echo "</script>";
header('Location: addCarHome.php');
exit;
} else {
$resultMessage = "Failed to query into database";
echo "<script>";
echo "alert('Failed to query into database')";
echo "</script>";
}
} else {
// If statement is error why see the code
die('Critical error:' . db2_stmt_error());
}
db2_free_stmt($stmt);
db2_close($conn);
} else {
echo db2_conn_errormsg();
}
}
示例8: uploadReserve
function uploadReserve()
{
if ($_POST['form_token'] != $_SESSION['form_token']) {
header('Location:reserved.php');
} else {
//print_r($_POST);
if (isset($_POST)) {
$name = $_POST['reserved_name'];
$resered_date = $_POST['reserved_date'];
$mobile = $_POST['mobile'];
$vehi_type = $_POST['type'];
$quantity = $_POST['quantity'];
$email = $_POST['email'];
// an array that want to insert this can be multiple array at the time.
$data = array($name, $resered_date, $mobile, $vehi_type, $quantity, $email);
// 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.
$sql = 'INSERT INTO EMM_ZOO.PARKRESERVETOUR (PARKRESERVENO, RESERVE_NAME, RESERVE_DATE, PHONE, VEHI_TYPE, AMOUNT, EMAIL) VALUES (DEFAULT,?,?,?,?,?,?);';
//echo $sql;
// prepare statement using connection and sql
$stmt = db2_prepare($conn, $sql);
// If statement is valid execute it to db2
if ($stmt) {
//echo "SQL is valid<br>";
$result = db2_execute($stmt, $data);
if ($result) {
$resultMessage = 1;
return $resultMessage;
header('Location: reserved.php#reserve_list');
exit;
} else {
$resultMessage = 0;
return $resultMessage;
}
} else {
// If statement is error why see the code
die('Critical error:' . db2_stmt_error());
}
db2_free_stmt($stmt);
db2_close($conn);
} else {
echo db2_conn_errormsg();
}
}
}
示例9: updateTicket
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: uploadPubMedInfo
function uploadPubMedInfo()
{
if (!isset($_SESSION['current_user_name']) && !isset($_COOKIE[$cookie_name])) {
header('Location: ../login.php');
exit;
} else {
//print_r($_POST);
if (isset($_POST)) {
$PUBMEDID = $_POST['PUBMEDID'];
$Title = $_POST['Title'];
$Year = $_POST['Year'];
$Author = $_POST['Author'];
$Journal = $_POST['Journal'];
$ResearchType = $_POST['ResearchType'];
$data = array($PUBMEDID, $Title, $Year, $Author, $Journal, $ResearchType);
// print var_dump to display an array of variable data with type that prepare for query.
//echo var_dump($data) ."<br>";
}
require_once '/var/www/html/app/model/connect.php';
$conn = dbConnect();
if ($conn) {
// DEFAULT if you set generated as identify with specifier this will auto increament for integer.
$sql = 'INSERT INTO EMM_ZOO.PUBMEDREFERENCES (PUBMEDID,TITLE,YEAR,AUTHOR,JOURNAL,RESEARCH_TYPE) VALUES (?,?,?,?,?,?);';
//echo $sql;
// prepare statement using connection and sql
$stmt = db2_prepare($conn, $sql);
// If statement is valid execute it to db2
if ($stmt) {
//echo "SQL is valid<br>";
$result = db2_execute($stmt, $data);
if ($result) {
$resultMessage = "Successfully added to Biological information";
echo "Successfully added";
header('Location: PubMedRef.php');
exit;
} else {
$resultMessage = "Failed to query into database";
}
} else {
// If statement is error why see the code
die('Critical error:' . db2_stmt_error());
}
db2_free_stmt($stmt);
db2_close($conn);
} else {
echo db2_conn_errormsg();
}
}
}
示例11: insertSaniEquip
function insertSaniEquip()
{
//print_r($_POST);
if (isset($_POST)) {
$equipid = $_POST['equipid'];
$equipname = $_POST['equipname'];
$equiptype = $_POST['equiptype'];
$status = 'Available';
// an array that want to insert this can be multiple array at the time.
$data = array($equipid, $equipname, $equiptype, $status);
// 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) {
$sql = 'INSERT INTO EMM_ZOO.SANITATION_EQUIP (EQUIPID, EQUIPNAME, EQUIPTYPE, STATUS) VALUES (?,?,?,?);';
// prepare statement using connection and sql
$stmt = db2_prepare($conn, $sql);
// If statement is valid execute it to db2
if ($stmt) {
//echo "SQL is valid<br>";
$result = db2_execute($stmt, $data);
if ($result) {
$resultMessage = "Successfully added to sanitation equipment";
//echo "Successfully added";
echo "<script>";
echo "alert('Added successfully')";
echo "</script>";
header('Location: addEquipHome.php');
exit;
} else {
$resultMessage = "Failed to query into database";
echo "<script>";
echo "alert('Failed to query into database')";
echo "</script>";
}
} else {
// If statement is error why see the code
die('Critical error:' . db2_stmt_error());
}
db2_free_stmt($stmt);
db2_close($conn);
} else {
echo db2_conn_errormsg();
}
}
示例12: CharacterUpload
function CharacterUpload()
{
if (isset($_POST)) {
$AnimalID = $_POST['AnimalID'];
$RecordID = $_POST['RecordID'];
$EmpID = $_POST['EmpID'];
$Height = $_POST['Height'];
$Weight = $_POST['Weight'];
$Length = $_POST['Length'];
$Pattern = $_POST['Pattern'];
$BodyTemperature = $_POST['BodyTemperature'];
// an array that want to insert this can be multiple array at the time.
$data = array($AnimalID, $RecordID, $EmpID, $Height, $Weight, $Length, $Pattern, $BodyTemperature);
// print var_dump to display an array of variable data with type that prepare for query.
//echo var_dump($data) ."<br>";
}
$conn = dbConnect();
if ($conn) {
// DEFAULT if you set generated as identify with specifier this will auto increament for integer.
$sql = "INSERT INTO EMM_ZOO.ANIMAL_CHARACTORISTICS (ANIMALID, RECORDID, EMPID, HEIGHT, WEIGHT, LENGTH, PATTERN, BODYTEMP) VALUES (?,?,?,?,?,?,?,?);";
echo $sql;
// prepare statement using connection and sql
$stmt = db2_prepare($conn, $sql);
// If statement is valid execute it to db2
if ($stmt) {
//echo "SQL is valid<br>";
$result = db2_execute($stmt, $data);
if ($result) {
$resultMessage = "Successfully added to Biological information";
echo "Successfully added";
header('Location: AnimalCharacter.php');
exit;
} else {
$resultMessage = "Failed to query into database";
}
} else {
// If statement is error why see the code
die('Critical error:' . db2_stmt_error());
}
db2_free_stmt($stmt);
db2_close($conn);
} else {
echo db2_conn_errormsg();
}
}
示例13: uploadPromotion
function uploadPromotion()
{
if (isset($_POST)) {
$PromoName = $_POST['PromoName'];
$PromoID = $_POST['PromoID'];
$ProStart = $_POST['ProStart'];
$ProEnd = $_POST['ProEnd'];
$ProductNO = $_POST['ProductNO'];
$PromType = $_POST['PromType'];
// an array that want to insert this can be multiple array at the time.
$data = array($PromoID, $ProStart, $ProEnd, $ProductNO, $PromType, $PromoName);
// 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.
$sql = 'INSERT INTO EMM_ZOO.PROMOTION(PROMOID, PROSTART, PROEND, PRODUCTNO, PROTYPE,PROMONAME) VALUES (?,?,?,?,?,?);';
echo $sql;
// prepare statement using connection and sql
$stmt = db2_prepare($conn, $sql);
// If statement is valid execute it to db2
if ($stmt) {
//echo "SQL is valid<br>";
$result = db2_execute($stmt, $data);
if ($result) {
$resultMessage = "Successfully added to parking reserved";
//echo "Successfully added";
header("Refresh:0; url=promotion.php");
// you must refresh page after insert, define specific page you want to refresh , header("Refresh:0"); it mean refresh current page
} else {
$resultMessage = "Failed to query into database";
}
} else {
// If statement is error why see the code
die('Critical error:' . db2_stmt_error($stmt));
}
db2_free_stmt($stmt);
db2_close($conn);
} else {
echo db2_conn_errormsg($conn);
}
}
示例14: dbQuery
function dbQuery($query, $show_errors = true, $all_results = true, $show_output = true)
{
if ($show_errors) {
error_reporting(E_ALL);
} else {
error_reporting(E_PARSE);
}
// Connect to the IBM DB2 database management system
$link = db2_pconnect("testdb", "db2inst1", "testpass");
if (!$link) {
die(db2_conn_errormsg());
}
// Print results in HTML
print "<html><body>\n";
// Print SQL query to test sqlmap '--string' command line option
//print "<b>SQL query:</b> " . $query . "<br>\n";
// Perform SQL injection affected query
$stmt = db2_prepare($link, $query);
$result = db2_execute($stmt);
if (!$result) {
if ($show_errors) {
print "<b>SQL error:</b> " . db2_stmt_errormsg($stmt) . "<br>\n";
}
exit(1);
}
if (!$show_output) {
exit(1);
}
print "<b>SQL results:</b>\n";
print "<table border=\"1\">\n";
while ($line = db2_fetch_array($stmt)) {
print "<tr>";
foreach ($line as $col_value) {
print "<td>" . $col_value . "</td>";
}
print "</tr>\n";
if (!$all_results) {
break;
}
}
print "</table>\n";
print "</body></html>";
}
示例15: executePreparedStatement
/**
* (non-PHPdoc)
* @see PreparedStatement::executePreparedStatement()
*/
public function executePreparedStatement(array $data, $msg = '')
{
if (!$this->stmt) {
$this->DBM->registerError($msg, "No prepared statement to execute");
return false;
}
$this->DBM->countQuery($this->parsedSQL);
$GLOBALS['log']->info("Executing Query: {$this->parsedSQL} with " . var_export($data, true));
$i = 0;
foreach ($data as $v) {
$i++;
$k = 'bind_' . $i;
${$k} = $v;
db2_bind_param($this->stmt, $i, $k, DB2_PARAM_IN);
}
$this->query_time = microtime(true);
$res = db2_execute($this->stmt);
return $this->finishStatement($res, $msg);
}