// IAM试图加载与输入数组和检查,然后输入如何设定规则,表单验证我的自定义库中的笨
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Slider{
public $ci;
public $ci2;
protected $CI;
function __construct() {
// reference to the CodeIgniter super object
$this->CI =& get_instance();
$this->ci =&get_instance();
$this->ci->load->model('Slider_Model');
$this->CI->load->library('form_validation');
}
//负荷数组保存数据的输入和检查输入,然后保存数据enter image description here
function AddSlide($Data){
$this->CI->load->library('form_validation');
$this->CI->form_validation->set_error_delimiters('<p style="color: red">', '</p>');
$this->CI->form_validation->set_rules($Data['Title'],$Data['Title'],'min_length[5]|max_length[20]');
$this->CI->form_validation->set_rules($Data['Description'],$Data['Description'],'min_length[10]|max_length[100]');
$this->CI->form_validation->set_rules($Data['Status'],$Data['Status'],'in_list[1,2]');
if ($this->CI->form_validation->run() == FALSE)
{
echo FALSE;
}
else
{
$this->ci->Slider_Model->AddNewSlid($Data);
}
}
}
词不等于CI。确保$ this-> ci是$ this-> CI –