|
 |
|
call stored procedure ตัวเดียวกัน 3 ครั้งไม่ได้ครับ |
|
 |
|
|
 |
 |
|
อาการคือ Call Store ที่ 1 ได้ครับ 2-3 ไม่ได้ เลยลองย้าย คำสั่ง Call Store ที่ 2 มาไว้อัน 1 กลับเรียกได้ จะทำยังไงให้มันเรียก พร้อมกัน โดย Store ตัวเดียวกัน แต่ผลออกมา 3 แบบ คนละตัวแปร อะครับ
มันขึ้น ERROR ว่า Fatal error: Call to a member function fetch_assoc() on a non-object in C:\AppServ\www\IT\helpdesk_detail.php on line 95
Code (C#)
<?php
session_start();
include("checkauthen.php");
include("connect.php");
$mysqli->set_charset('utf8');
$resultRecent = $mysqli->query("CALL `pt_it`.`spgetHelpDeskQueue`('".$_SESSION['employee_ID']."','1','3');");
$mysqli->set_charset('utf8');
$resultAccept = $mysqli->query("CALL `pt_it`.`spgetHelpDeskQueue`('".$_SESSION['employee_ID']."','2','3');");
$mysqli->set_charset('utf8');
$resultFinish = $mysqli->query("CALL `pt_it`.`spgetHelpDeskQueue`('".$_SESSION['employee_ID']."','3','3');");
?>
<!DOCTYPE html>
<html>
<head>
<title>IT Support</title>
<link rel="stylesheet" href="css/stylesheet.css" type="text/css" />
<link href="css/icon.ico" rel="icon" type="image/x-icon" />
<style type="text/css">
.center {
text-align: center;
}
body,td,th {
font-family: THSarabunNew, sans-serif;
}
body {
background-image: url(css/BG/IT.png);
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<table width="1024" border="0" align="center">
<tr>
<td align="center">
<table width="100%" border="0">
<tr>
<td colspan="3" align="center" bgcolor="#FF00FF"><p>BANNER</p></td>
</tr>
<tr>
<td width="13%" rowspan="2" bgcolor="#00FFFF"><p><a href="logout.php">Logout</a></p>
<p><a href="index.php">Main</a></p>
<p>Help Desk</p></td>
<td align="left" bgcolor="#00FF00">Help Desk</td>
<td align="right" bgcolor="#00FF00">ยินดีต้อนรับ <? echo $_SESSION['Name'] ?></td>
</tr>
<tr>
<td colspan="2" align="center">
<? echo $resultAccept->num_rows;?> ใบแจ้งล่าสุด
<table width="100%" border="1">
<tr>
<td><table width="100%" border="0">
<tr>
<td width="20%" align="center" bgcolor="#FFCCCC">วันที่ให้เข้าปฏิบัติงาน</td>
<td width="50%" align="center" bgcolor="#FFCCCC">รายละเอียด</td>
<td width="12%" align="center" valign="middle" bgcolor="#FFCCCC">สถานะ</td>
</tr>
<tr>
<?
$colour=1;
while ($item = $resultRecent->fetch_assoc()) {
?>
<tr <? if(($colour%2)==0){?>bgcolor="#D6D6D6"<? }else{?>bgcolor="#8080FF"<? }?>>
<td align="center"><span class="center"><? echo $item[date_inform_service] ?></span></td>
<td align="center"><span class="center"><? echo $item[detail] ?></span></td>
<td align="center"><span class="center"><? echo $item[name_status] ?></span></td>
</tr>
<?
$colour++;
}
$resultRecent->free();
?>
</table></td>
</tr>
</table>
รับเรื่องแล้ว
<table width="100%" border="1">
<tr>
<td><table width="100%" border="0">
<tr>
<td width="20%" align="center" bgcolor="#FFCCCC">วันที่ให้เข้าปฏิบัติงาน</td>
<td width="50%" align="center" bgcolor="#FFCCCC">รายละเอียด</td>
<td width="12%" align="center" valign="middle" bgcolor="#FFCCCC">สถานะ</td>
</tr>
<tr>
<?
$colour=1;
while ($item = $resultAccept->fetch_assoc()) {
?>
<tr <? if(($colour%2)==0){?>bgcolor="#D6D6D6"<? }else{?>bgcolor="#8080FF"<? }?>>
<td align="center"><span class="center"><? echo $item[date_inform_service] ?></span></td>
<td align="center"><span class="center"><? echo $item[detail] ?></span></td>
<td align="center"><span class="center"><? echo $item[name_status] ?></span></td>
</tr>
<?
$colour++;
}
$resultAccept->free();
?>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
รายการเสร็จสิ้น
<table width="100%" border="1">
<tr>
<td><table width="100%" border="0">
<tr>
<td width="20%" align="center" bgcolor="#FFCCCC">วันที่ให้เข้าปฏิบัติงาน</td>
<td width="50%" align="center" bgcolor="#FFCCCC">รายละเอียด</td>
<td width="12%" align="center" valign="middle" bgcolor="#FFCCCC">สถานะ</td>
</tr>
<tr>
<?
$colour=1;
while ($item = $resultFinish->fetch_assoc()) {
?>
<tr <? if(($colour%2)==0){?>bgcolor="#D6D6D6"<? }else{?>bgcolor="#8080FF"<? }?>>
<td align="center"><span class="center"><? echo $item[date_inform_service] ?></span></td>
<td align="center"><span class="center"><? echo $item[detail] ?></span></td>
<td align="center"><span class="center"><? echo $item[name_status] ?></span></td>
</tr>
<?
$colour++;
}
$resultFinish->free();
?>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<p> </p>
<p>
<input type="submit" name="Add" id="Add" value="Add" onClick="window.location.href='helpdesk_add.php'"/>
</p></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
ขอบคุณมากครับ
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2014-06-16 11:58:17 |
By :
teerapat_kan |
View :
1241 |
Reply :
8 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยัง งงๆ อยู่เลยอะครับ แต่ก็ขอบคุณมากนะครับ
เท่าที่ผมเข้าใจคือ Mysqli จะ ต้องเอา Result ที่เรา Query ได้ไป Dump ใส่อะไรไว้สักอย่างแล้ว ก็ clearStoredResults คือ Function ที่เราใส่ไว้ใน Code เราถูกต้องไหมครับ จึงดำเนินการ Query อันต่อไปได้ ถูกต้องไหมครับ มีความเห็นอย่างไรเสนอได้นะครับ งมมาตลอดครึ่งเช้าแล้วครับ Error ที่เดิมเลยครับ ขอบคุณมากครับ
Code (PHP)
<?php
session_start();
include("checkauthen.php");
include("connect.php");
$mysqli->set_charset('utf8');
$resultRecent = $mysqli->query("CALL `pt_it`.`spgetHelpDeskQueue`('".$_SESSION['employee_ID']."','1','3');", MYSQLI_STORE_RESULT);
/////////////////////////////////Start Function ที่เพิ่มเข้าไปครับ////////////////////////////////////////////////////////////////////////////////////////////
#------------------------------------------
function clearStoredResults($mysqli_link)
{
#------------------------------------------
while($mysqli_link->next_result()){
if($l_result = $mysqli_link->store_result()){
$l_result->free();
}
}
}
/////////////////////////////////End Function ที่เพิ่มเข้าไปครับ////////////////////////////////////////////////////////////////////////////////////////////
?>
<!DOCTYPE html>
<html>
<head>
<title>IT Support</title>
<link rel="stylesheet" href="css/stylesheet.css" type="text/css" />
<link href="css/icon.ico" rel="icon" type="image/x-icon" />
<style type="text/css">
.center {
text-align: center;
}
body,td,th {
font-family: THSarabunNew, sans-serif;
}
body {
background-image: url(css/BG/IT.png);
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<table width="1024" border="0" align="center">
<tr>
<td align="center">
<table width="100%" border="0">
<tr>
<td colspan="3" align="center" bgcolor="#FF00FF"><p>BANNER</p></td>
</tr>
<tr>
<td width="13%" rowspan="2" bgcolor="#00FFFF"><p><a href="logout.php">Logout</a></p>
<p><a href="index.php">Main</a></p>
<p>Help Desk</p></td>
<td align="left" bgcolor="#00FF00">Help Desk</td>
<td align="right" bgcolor="#00FF00">ยินดีต้อนรับ <? echo $_SESSION['Name'] ?></td>
</tr>
<tr>
<td colspan="2" align="center">
ใบแจ้งล่าสุด
<table width="100%" border="1">
<tr>
<td><table width="100%" border="0">
<tr>
<td width="20%" align="center" bgcolor="#FFCCCC">วันที่ให้เข้าปฏิบัติงาน</td>
<td width="50%" align="center" bgcolor="#FFCCCC">รายละเอียด</td>
<td width="12%" align="center" valign="middle" bgcolor="#FFCCCC">สถานะ</td>
</tr>
<tr>
<?
$colour=1;
while ($item = $resultRecent->fetch_assoc()) {
?>
<tr <? if(($colour%2)==0){?>bgcolor="#D6D6D6"<? }else{?>bgcolor="#8080FF"<? }?>>
<td align="center"><span class="center"><? echo $item[date_inform_service] ?></span></td>
<td align="center"><span class="center"><? echo $item[detail] ?></span></td>
<td align="center"><span class="center"><? echo $item[name_status] ?></span></td>
</tr>
<?
$colour++;
}
/////////////////////////////////Start เรียกFunction ที่เพิ่มเข้าไปครับ////////////////////////////////////////////////////////////////////////////////////////////
clearStoredResults($mysqli);
/////////////////////////////////End เรียกFunction ที่เพิ่มเข้าไปครับ////////////////////////////////////////////////////////////////////////////////////////////
$mysqli->set_charset('utf8');
$resultAccept = $mysqli->query("CALL `pt_it`.`spTest`('".$_SESSION['employee_ID']."','2','3');",MYSQLI_STORE_RESULT);
?>
</table></td>
</tr>
</table>
<? echo $resultAccept->num_rows;?>รับเรื่องแล้ว
<table width="100%" border="1">
<tr>
<td><table width="100%" border="0">
<tr>
<td width="20%" align="center" bgcolor="#FFCCCC">วันที่ให้เข้าปฏิบัติงาน</td>
<td width="50%" align="center" bgcolor="#FFCCCC">รายละเอียด</td>
<td width="12%" align="center" valign="middle" bgcolor="#FFCCCC">สถานะ</td>
</tr>
<tr>
<?
$colour=1;
while ($item = $resultAccept->fetch_assoc()) {
?>
<tr <? if(($colour%2)==0){?>bgcolor="#D6D6D6"<? }else{?>bgcolor="#8080FF"<? }?>>
<td align="center"><span class="center"><? echo $item[date_inform_service] ?></span></td>
<td align="center"><span class="center"><? echo $item[detail] ?></span></td>
<td align="center"><span class="center"><? echo $item[name_status] ?></span></td>
</tr>
<?
$colour++;
}
$resultAccept->free();
?>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
รายการเสร็จสิ้น
<table width="100%" border="1">
<tr>
<td><table width="100%" border="0">
<tr>
<td width="20%" align="center" bgcolor="#FFCCCC">วันที่ให้เข้าปฏิบัติงาน</td>
<td width="50%" align="center" bgcolor="#FFCCCC">รายละเอียด</td>
<td width="12%" align="center" valign="middle" bgcolor="#FFCCCC">สถานะ</td>
</tr>
<tr>
<?
$colour=1;
while ($item = $resultFinish->fetch_assoc()) {
?>
<tr <? if(($colour%2)==0){?>bgcolor="#D6D6D6"<? }else{?>bgcolor="#8080FF"<? }?>>
<td align="center"><span class="center"><? echo $item[date_inform_service] ?></span></td>
<td align="center"><span class="center"><? echo $item[detail] ?></span></td>
<td align="center"><span class="center"><? echo $item[name_status] ?></span></td>
</tr>
<?
$colour++;
}
$resultFinish->free();
?>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<p> </p>
<p>
<input type="submit" name="Add" id="Add" value="Add" onClick="window.location.href='helpdesk_add.php'"/>
</p></td>
</tr>
</table>
/td>
</tr>
</table>
</body>
</html>
|
ประวัติการแก้ไข 2014-06-17 14:00:30
 |
 |
 |
 |
Date :
2014-06-17 13:58:14 |
By :
teerapat_kan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รบกวนด้วยนะครับ
|
 |
 |
 |
 |
Date :
2014-06-19 00:23:33 |
By :
teerapat_kan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
.
|
 |
 |
 |
 |
Date :
2014-06-23 10:03:25 |
By :
teerapat_kan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
007.$resultRecent = $mysqli->query("CALL `pt_it`.`spgetHelpDeskQueue`('".$_SESSION['employee_ID']."','1','3');", MYSQLI_STORE_RESULT);
ลองเช็คแบบง่ายๆ ก่อนไหมครับ
แก้เป็น
Code (PHP)
$resultRecent = $mysqli->query($qr="CALL `pt_it`.`spgetHelpDeskQueue`('".$_SESSION['employee_ID']."','1','3');", MYSQLI_STORE_RESULT);
// แทรกบันทัดข้างล่างนี้ครับ
if(!$resultRecent){
echo $qr, "<br/>\n";
printf("Error: %s\n", $mysqli->error); exit;
}
บันทัดไหนที่มีการ query ก็ทำแบบเดียวกันเป็น pattern เลยครับ
พอโปรแกรมสมบูรณ์ดีแล้ว ค่อตัดตัวเช็คพวกนี้ออกครับ
|
 |
 |
 |
 |
Date :
2014-06-23 10:33:09 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไว้ศึกษาตรงนี้ ก่อนครับ แต่ตอนนี้
คงต้องแก้โดยการ ทำ buffer เก็บ result ไว้ก่อนแล้วครับ แล้วก็ free resut ไปก่อนที่จะเรียกใหม่
แต่อันนี้ไม่สดวกกับข้อมูลเยอะๆ ไม่รู้ว่า Server จะเก็บได้เยอะขนาดไหน
Code (PHP)
function saveResult($result){
$buffer=array()
while ($item = $resultAccept->fetch_assoc()) {
$buffer[]=$item;
} $result->free();
return $buffer;
}
$buf=saveResult($resultName);
|
 |
 |
 |
 |
Date :
2014-06-23 11:07:10 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|