我有一个注册表。成功后,我想删除set_value值并取消设置所有发布的值。
查看.php
<?php echo validation_errors(); ?>
<?php if(isset($msg)){
echo $msg;
} ?>
<form action="" method="post">
<h5>Username</h5>
<input type="text" name="username" value="<?php echo set_value('username'); ?>" size="50" />
<h5>Password</h5>
<input type="text" name="password" value="<?php echo set_value('password'); ?>" size="50" />
<div>
<input type="submit" value="Submit" />
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
控制器函数.php
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
if ($this->form_validation->run() == FALSE){
$data->msg='Please fill all field';
$this->load->view('view',$data);
}else{
$data->msg='success';
unset($_POST);
$this->load->view('view',$data);
}
Run Code Online (Sandbox Code Playgroud)
我尝试unset($_POST)但没有奏效,也尝试
public function clear_field_data() {
$this->_field_data = array();
return $this; …Run Code Online (Sandbox Code Playgroud) 如何在Codeigniter中运行删除查询。我有一组数组和一个键。在MySQL中,我的查询运行完美。
DELETE FROM `TABLE` WHERE `style_id`=2 && `ID` NOT IN (5,9,12)
Run Code Online (Sandbox Code Playgroud)
在Codeigniter中,如何编写和运行此查询。我尝试了下面的代码,但无法正常工作。
$ids = '5,9,12';
$this->db->where('style_id', $style_id)->where_not_in('ID', $ids);
$this->db->delete('TABLE');
Run Code Online (Sandbox Code Playgroud)