我想将函数randstring调用到视图输入中。如果有人知道,请帮助别人。
class Quote extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('model_quote');
}
public function randstring(){
$characters = '0123456789';
$randomString = 'Q';
for ($i = 0; $i < 5; $i++) {$randomString .= $characters[rand(0, strlen($characters) - 1)];}
$random = $randomString;
$r = $this->db->get_where('quotation_parent',array('qoute_no'=>$random))->row_array();
if(!empty($r)){
$this->randstring();
}else{
return $r['qoute_no'];
}
}
}