我想为客户分配一张卡,我想获得未分配的卡号。假设我有 2 类卡:1 是签证卡,2 是预付卡。我想在分配万事达卡时只需要显示万事达卡的未分配卡号和签证卡相同的卡号。这是我的代码。
型号代码
function getUnallocatedCards($object)
{
$this->db->select('*');
$this->db->from('cards');
$this->db->where('catagory_id',$object->catagory_id);
$this->db->where('status',$object->status);
$query = $this->db->get();
echo $this->db->last_query();
if($query->num_rows() == 0){
return null;
}
return $query->result();
}
控制器
public function AllocateCustomerCards($id='')
{
$userinfo='';
$contentObj='';
$submit=$this->input->post('submit');
if($submit=='submit')
{
$userinfo->customer_id = $this->input->post('cust_id');
$userinfo->status_id = $this->input->post('status_id');
$userinfo->card_number = $this->input->post('card_number');
$userinfo->card_id = $this->input->post('card_id');
$userinfo->print_date =$this->input->post('print_date');
$userinfo->issue_date =$this->input->post('issue_date');
$this->Cards_model->saveCardAllocat($userinfo);
echo $this->db->last_query();
}
$contentObj['unallocatedcards']=$this->Cards_model->getUnallocatedCards($userinfo);
$contentObj['cardtype']=$this->Cards_model->cardCatagories();
$contentObj['cardrequest']=$this->Cards_model->getCustomerCardRequst($id);
$this->load->view('admin/cardsystem/allocate_card',$contentObj);
}
看法
<tr><td><label>Select Card No. :</label><span style="display:inline;color:red;"> *</span> </td>
<td>
<select name="card_number" id="card_number" class="medium-input">
<option value=""> -- Select Card No. -- </option>
<?php
foreach($unallocatedcards as $customer)
{
echo '<option value="'.$customer->card_no.'">'.$customer->card_no.'</option>';
}
?>
</select><span class="input-notification error png_bg" id="error_number_id" style="display:none;"></span>
</td>
</tr>
但它显示以下错误
遇到 PHP 错误
严重性:通知
消息:尝试获取非对象
文件名的属性:models/cards_model.php
行号:339遇到 PHP 错误
严重性:通知
消息:尝试获取非对象
文件名的属性:models/cards_model.php
行号:340
第 339 行:
$this->db->where('catagory_id',$object->catagory_id);
第 340 行:
$this->db->where('status',$object->status);
我打印查询,这是我的查询结果:
SELECT * FROM (`cards`) WHERE `catagory_id` IS NULL AND `status` IS NULL