Welcome Guest, Not a member yet? Register   Sign In
Help! delete record doesn’t work
#1

[eluser]red apple[/eluser]
Hi everyone,

I'm new in this forum and also I'm learning to use the CI. I was able to finish an project using CI and everything works great with an little exception. Even if I try to find my error, I could not solve my probleme.

Here below you can see my model delete function:

function delete_cd($cd_id, $cd_name, $cd_type, $cd_description)
{
$data = array('cd_id'=> $cd_id, 'cd_name' => $cd_name, 'cd_type' => $cd_type, 'cd_description' => $cd_description);
if($cd_id)
{
$this->db->where('cd_id', $cd_id);
$this->db->delete('audio');
}
}

And here is my controler's function:

function delete_cd()
{
$this->load->model('Videotek');
$cd_id = $_POST['txtcd_id'];
$this->db->set('cd_id', $cd_id);
$cd_name = $_POST['txtcd_name'];
$this->db->set('cd_name', $cd_name);
$cd_type = $_POST['txtcd_type'];
$this->db->set('cd_type', $cd_type);
$cd_description = $_POST['txtcd_description'];
$this->db->set('cd_description', $cd_description);

$data['query'] = $this->Videotek->delete_cd($cd_id, $cd_name, $cd_type, $cd_description);

$data['query'] = $this->Videotek->get_info($username);
$this->load->view('vaudio', $data);
}

Thanks in advance
I realy need to solv that probleme, .... my due date for this project is tomorrow ...
Sorry for my englesh
#2

[eluser]nandish[/eluser]
try this function in Model
//ignore other three paramets
function delete_cd($cd_id, $cd_name, $cd_type, $cd_description){
if($cid){
$sql = "DELETE from audio where cd_id= ?";
$this->$db->query($sql,array($cd_id));
}
}

controller

function delete_cd(){
$this->load->Model('Videotek’);
$this->load->view(’vaudio’, $data);
$data['query'] = $cd_id = $_POST[’txtcd_id’];
$data['query'] = $this->Videotek->delete_cd($cd_id);
}

I dint get why you are using $this->db->set();
Are u updting ?
#3

[eluser]nandish[/eluser]
sorry!
controller

function delete_cd(){
$this->load->Model(’Videotek’);
$cd_id = $_POST[’txtcd_id’];
$data[’query’] = $this->Videotek->delete_cd($cd_id);
$this->load->view(’vaudio’, $data);
}
#4

[eluser]red apple[/eluser]
Thanks for your answer, unfortunatelly works not and I have an error message:

Error number: 1054
Unknown column '10126' in 'where clause'
DELETE from audio where cd_id = 10126

the 10126 is the cd id, I want to delete from my videotek.
#5

[eluser]nandish[/eluser]
just replace from audio to videotek

DELETE from videotek where cd_id = ?";
#6

[eluser]red apple[/eluser]
Hi!

Thanks again for your answer, but there is the never ending story ... It's stupid, I was able to solv difficult problems and now I'm stocked here ...

I could not replace the audio with videotek, because the videotek is my database who contain a lot of table like audio, video ... I want to delete an cd from my data base, which is found in audio table.
I have the modiffy function and I use the cd id also and all work great, but for delete ...doesn't matter how I wrote the function I have the same error message.

escuse my englesh




Theme © iAndrew 2016 - Forum software by © MyBB