我需要使用此代码从db获取service_price
字段。
public function get_service_price($id) {
$this->db->select('*');
$this->db->from('service');
$this->db->where('id', $id);
$query = $this->db->get('service');
return $query->row('service_price');
}
这里我调用了这个函数函数。
public function vat($vat=14.5)
{
$id = $this->uri->segment(4);
$data['service_price'] = $this->service_model->get_service_price($id);
$price_with_vat=0;
$price_with_vat = $data + ($vat*($data/100));
//$price_with_vat=78.005;
$price_with_vat = round($price_with_vat, 2);
$this->load->view('admin/service/vat', $price_with_vat);
}
有些错误。请帮助我
答案 0 :(得分:0)
要获得第一行
$query = $this->db
->where('id', $id);
->get('service');
$firstRow = $query->first_row();
return $firstRow->service_price;
答案 1 :(得分:0)
在模型中
D2
控制器中的
class D2 : public B2{
public:
virtual void foo() override { cout << __PRETTY_FUNCTION__ << '\n'; }
};
class D :public B1, public D2
{};
D d;
// d.foo(); // error - ambiguous
D2& d2 = d;
d2.foo(); // calls D2::foo
B2& b2 = d;
b2.foo(); // calls D2::foo
B1& b1 = d;
b1.foo(); // calls B1::foo
在视图中
public function get_service_price($id) {
$query = $this->db->query("SELECT * FROM service WHERE id='$id'");
$result = $query->result_array();
return $result;
}
答案 2 :(得分:0)
将此代码用于您的模型:
try this may work for you
$.ajax({
type: "POST",
url: 'http://localhost:8080/IDNS_Rule_Configuration/idns/idnsData/importYaml',
enctype: "multipart/form-data",
data: formData,
processData: false,
contentType: false,
success: function (data) {
//some success functions
}
});