|
 |
|
ถามเรื่องการ update codeigniter หลาย table หน่อยครับ |
|
 |
|
|
 |
 |
|
คือผมจะ update ข้อมูล หลาย table แต่ไม่มี error และค่าไม่ส่งมาด้วยครับ ช่วยดูทีครับ
model
Code (PHP)
function receive_mobile($data){
$strSQL = "UPDATE [phone] SET ";
$strSQL .="borrow = '0' ";
$strSQL .="WHERE id = '".$data["id_phone"]."' ";
$objQuery = mssql_query($strSQL);
if($objQuery)
{
$remark = "UPDATE [borrow_phone] SET ";
$remark .="remark = '".$data["remark"]."' ";
$remark .=", date_receive = '".$data["date"]."' ";
$remark .=", borrow = '0' ";
$remark .="WHERE id = '".$data["id_borrow_phone"]."' ";
$checkremark = mssql_query($remark);
if($checkremark)
{
$borrow = "UPDATE [borrow] SET ";
$borrow .="sender = '".$data["sender"]."' ";
$borrow .=", receive = '".$data["receive"]."' ";
$borrow .="WHERE id = '".$data["id_borrow"]."' ";
$checkborrow = mssql_query($borrow);
if($checkborrow)
{
return true;
}
else
{
return false;
}
}
else
{
echo "Error Save [".$remark."]";
}
}
else
{
echo "Error Save [".$strSQL."]";
}
}
controller
Code (PHP)
public function receive_mobile()
{
$data['id_phone']= $this->input->post('id');
$data['id_borrow']= $this->input->post('id');
$data['id_borrow_phone']= $this->input->post('id');
$data['date']= $this->input->post('date_receive');
$data['sender']= $this->input->post('sender');
$data['receive']= $this->input->post('receive');
$data['remark']= $this->input->post('remark');
$create = $this->phone_system_model->receive_mobile($data);
if($create){
$this->index();
}else{
error_log("Unsuccess");
}
}
view
Code (PHP)
<input type="hidden" value="<?=$borrow_phones->id;?>" name="id_borrow_phone">
<input type="hidden" value="<?=$id_phone;?>" name="id_phone">
<input type="hidden" value="<?=$borrows->id;?>" name="id_borrow">
<select name="sender" style="width:200px;">
<option value="">--- เลือก ---</option>
<?PHP
foreach($member as $members):
?>
<option value="<?=$members->id;?>"><?=iconv('tis-620','utf-8',$members->name)." ".iconv('tis-620','utf-8',$members->lastname);?></option>
<?PHP
endforeach;
?>
</select>
<select name="receive" style="width:200px;">
<option value="">--- เลือก ---</option>
<?PHP
foreach($member as $members):
if($members->team == "1"):
?>
<option value="<?=$members->id;?>"><?=iconv('tis-620','utf-8',$members->name)." ".iconv('tis-620','utf-8',$members->lastname);?></option>
<?PHP
endif;
endforeach;
?>
</select>
</td>
<td><input type="text" class="datepicker" id="date<?=$borrow_phones->id;?>" name="date<?=$borrow_phones->id;?>" style="width:75px;"></td>
<td><input type="text" name="remark" size="50" maxlength="250" ></td>
<a class="btn btn-info" href="<?php echo site_url("phone_system/receive_mobile/".$id_phone ); ?>">
<i class="icon-edit icon-white"></i>
Receive
</a>
Tag : PHP, Ms SQL Server 2008

|
|
 |
 |
 |
 |
Date :
2013-05-19 19:10:03 |
By :
Nos1001 |
View :
894 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่ใช้ active record ของ ci ล่ะครับ ปลอดภัยกว่ากันเยอะ เขาอุตส่าห์มีมาให้.
|
 |
 |
 |
 |
Date :
2013-05-19 22:34:08 |
By :
mr.v |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|