我正在尝试(没有成功)更新/删除表中的行。
注意:我的数据库名称是" desafio"和表" materias"包含:(id,carrera_id(是列的外键" id"表" carreras")nombre,descripcion,carga_horaria)
单击按钮时出现这2个错误"编辑" &安培; "删除"分别为:
这是索引文件:
Traceback (most recent call last):
File "/Users/premanandlakshmanan/Documents/psilon/quantopian/mac_popup.py", line 2, in <module>
call(["""osascript -e 'tell app "System Events" to display dialog "Hello World" ' """])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
[Finished in 0.3s with exit code 1]
这是控制器文件(包含功能编辑,保存更新和删除)
<tbody>
<?php
foreach($records as $record) {
echo "<tr>
<td>".$record->id."</td>
<td>".$record->carrera."</td>
<td>".$record->nombre."</td>
<td>".$record->descripcion."</td>
<td>".$record->carga_horaria."</td>
<td align='center'>
<a href='".site_url('Home/edit')."/$record->id'>
<button type='button' class='btn btn-primary'>EDITAR</button></a> |
<a href='".site_url('Home/delete')."/$record->id'>
<button type='button' class='btn btn-danger'>BORRAR</button></a>
</tr>";
}
?>
crudmodel(函数get_row_id)
public function edit($id){
$data['record']=$this->Crudmodel->get_row_id($id);
$this->load->view('editar', $data);
}
public function saveupdate(){
$txtcarr=$this->input->post("txtcarr");
$txtmat=$this->input->post("txtmat");
$txtdesc=$this->input->post("txtdesc");
$txtcarga=$this->input->post("txtcarga");
$this->Crudmodel->save($txtcarr,$txtmat,$txtdesc,$txtcarga);
redirect('Home/index');
}
public function delete($id){
$this->db->where('id',$id);
$this->db->delete('desafio');
redirect('Home/index');
}
文件&#34; editar&#34;这使我能够纠正所写的信息:
public function get_row_id($id){
$this->db->where('id',$id);
$query=$this->db->get('id');
return $query->row();
}
</head>
不明白发生了什么:S
答案 0 :(得分:1)
在delete
函数中,您不应该使用表名吗?
$this->db->delete('materias');