这真是混淆不清。 我试图这样做的是。 我先把照片上载到服务器。 它向非行铺设道路。 我需要将生意的补贴附在光灯上。
这里我迄今为止所做的事情:
function get_bus_id() {
$userid = $this->tank_auth->get_user_id();
$this->db->select( b.id );
$this->db->from ( business AS b );
$this->db->where ( b.userid , $userid);
$query = $this->db->get();
if ($query->num_rows() > 0) {
// RESULT ARRAY RETURN A MULTIDIMENSIONAL ARRAY e.g. ARRAY OF DB RECORDS
// ( ROWS ), SO IT DOENS T FIT
//return $query->result_array();
// THE CORRECT METHOD IS row_array(), THAT RETURN THE FIRST ROW OF THE
// RECORDSET
$query->row_array();
}
这得到企业的id。 然后,我有上载功能,如下:
/* Uploads images to the site and adds to the database. */
function do_upload() {
$config = array(
allowed_types => jpg|jpeg|gif|png ,
upload_path => $this->gallery_path,
max_size => 2000
);
$this->load->library( upload , $config);
$this->upload->do_upload();
$image_data = $this->upload->data();
$config = array(
source_image => $image_data[ full_path ],
new_image => $this->gallery_path . /thumbs ,
maintain_ratio => true,
width => 150,
height => 100
);
$this->load->library( image_lib , $config);
$this->image_lib->resize();
$upload = $this->upload->data();
$bus_id = $this->get_bus_id();
$data = array(
userid => $this->tank_auth->get_user_id(),
thumb => $this->gallery_path . /thumbs/ . $upload[ file_name ],
fullsize => $upload[ full_path ],
busid => $bus_id[ id ],
);
echo var_dump($bus_id);
$this->db->insert( photos , $data);
}
我忘记的问题是:
A PHP Error
严重程度:通知
讯息:不明确的指数:id
档案名称:模型/加勒y_model.php
电话:48
我先尝试了获得价值的各种途径,但我的有限知识却不断发展。 任何帮助都会得到真正的赞赏。