これのせいで頭を壁にぶつけてる
私はこれが長い質問であることを知っていますが、それは私が持っているすべてです:(
私はCIを1年以上使用していますが、このエラーは私を殺しています 問題は、モデルからデータを取得しているため、返されることです
Unknown column 'albums' in 'where clause'</p><p>SELECT *
FROM (`albums`)
WHERE `id` = '1'
AND `albums` IS NULL
AND `id` = '1'
モデル関数は
function get($id = 0 )
{
if($id == 0 )
{
$q = $this->db->get('albums')->result();
return $q;
}
else
{
$this->db->where("id",$id);
$q = $this->db->get('albums');
return $q->row();
}
}
関数の呼び出しを削除すると、$data をデバッグするときに json_encode から別のエラーが発生し、次のようになります。
Array
(
[response] => CI_DB_mysql_driver Object
(
[dbdriver] => mysql
[_escape_char] => `
[_like_escape_str] =>
[_like_escape_chr] =>
[delete_hack] => 1
[_count_string] => SELECT COUNT(*) AS
[_random_keyword] => RAND()
[use_set_names] =>
[ar_select] => Array
(
)
[ar_distinct] =>
[ar_from] => Array
(
)
[ar_join] => Array
(
)
[ar_where] => Array
(
[0] => `id` = '1'
[1] => AND `albums` IS NULL
)
[ar_like] => Array
(
)
[ar_groupby] => Array
(
)
[ar_having] => Array
(
)
[ar_keys] => Array
(
)
[ar_limit] =>
[ar_offset] =>
[ar_order] =>
[ar_orderby] => Array
(
)
[ar_set] => Array
(
[`title`] => ' asdasd'
[`description`] => 'Hello '
)
[ar_wherein] => Array
(
)
[ar_aliased_tables] => Array
(
)
[ar_store_array] => Array
(
)
[ar_caching] =>
[ar_cache_exists] => Array
(
)
[ar_cache_select] => Array
(
)
[ar_cache_from] => Array
(
)
[ar_cache_join] => Array
(
)
[ar_cache_where] => Array
(
)
[ar_cache_like] => Array
(
)
[ar_cache_groupby] => Array
(
)
[ar_cache_having] => Array
(
)
[ar_cache_orderby] => Array
(
)
[ar_cache_set] => Array
(
)
[ar_no_escape] => Array
(
)
[ar_cache_no_escape] => Array
(
)
[username] => root
[password] => 123456
[hostname] => localhost
[database] => sawt
[dbprefix] =>
[char_set] => utf8
[dbcollat] => utf8_general_ci
[autoinit] => 1
[swap_pre] =>
[port] =>
[pconnect] => 1
[conn_id] => Resource id #30
[result_id] => 1
[db_debug] => 1
[benchmark] => 0.00059294700622559
[query_count] => 1
[bind_marker] => ?
[save_queries] => 1
[queries] => Array
(
[0] => UPDATE `pulling_questions` SET `status` = 0 WHERE `status` = 1 AND `end_date` <= 1359556250
)
[query_times] => Array
(
[0] => 0.00059294700622559
)
[data_cache] => Array
(
)
[trans_enabled] => 1
[trans_strict] => 1
[_trans_depth] => 0
[_trans_status] => 1
[cache_on] =>
[cachedir] =>
[cache_autodel] =>
[CACHE] =>
[_protect_identifiers] => 1
[_reserved_identifiers] => Array
(
[0] => *
)
[stmt_id] =>
[curs_id] =>
[limit_used] =>
[stricton] =>
)
)
get
上記のコードは別のコントローラーで完全に機能しており、ビューから呼び出した場合、モデルの呼び出しはエラーなしで行われます
この前に更新を呼び出しますが、これも更新されません
function update($id,$title,$description,$path)
{
$this->db->where('id',$id);
$this->db->set('title',$title);
$this->db->set('description',$description);
if($path != 'none')
$this->db->set('path',$path);
$q1 = $this->db->where('albums');
return $q1;
}
そして、ここにコントローラーメソッドがあります
public function update2($action = "show",$id = 0 ,$row = 0 )
{
$data = array();
if($action == "show"):
$data['id'] = $id;
$data['row_number'] = $row;
$this->load->view('albums/edit_album',$data);
else:
$id = $this->input->post('id');
$title = $this->input->post('title');
$description = $this->input->post('description');
$path = $this->session->userdata('image_name_album');
$this->form_validation->set_rules('title', 'Title', 'trim|required|xss_clean');
$this->form_validation->set_rules('description', 'Description', 'trim|required|xss_clean');
if ($this->form_validation->run() == FALSE):
$errors = array();
$errors = $this->form_validation->errors_array();
$data['errors'] = $errors;
$data['response'] = "Errors";
echo json_encode($data);
die();
else:
//update($id,$author,$title,$albums,$short,$lang,$status)
$data['response'] = $this->albums_model->update($id,$title,$description,$path);;
$data['query'] = $this->albums_model->get($id);
print_r($data);
echo json_encode($data);
die();
endif;
endif;
}