这是我的代码,
在添加"new Entity\UserAds($array);"
时总会产生错误
实体存在于"models\Entity\"
文件夹
use Entity\UserAds;
use Entity\Comment;
class postad extends CI_Controller {
protected $view_data;
public function __construct() {
parent::__construct ();
$this->load->helper ( array (
'form',
'url'
) );
$this->load->library ( 'form_validation' );
// view data
}
public function index() {
if ($this->form_validation->run() == FALSE) {
$this->view_data ['content'] = 'contents/postads';
$this->load->view ( 'templates/layout', $this->view_data );
} else {
$array = $this->input->post ();
try {
$ads = UserAds::createFromPost($array );
$this->em = $this->doctrine->em;
//$repository = $this->em->getRepository ( 'Entity\User' );
$this->em->persist ( $ads );
$this->em->flush ();
$this->session->set_flashdata ( 'err_msg', "" );
$this->log ( "create_post() created new ads." );
$this->view_data['count']=$this->input->post('count');
$this->view_data ['result'] = $ads;
$adid=$ads->getId();
$ads->getImages();
$this->session->set_userdata('id',$adid);
$this->load->model("emailmodel");
$this->emailmodel->send_notification($ads->getEmail(),$adid,$ads->getTitle());
if($this->session->userdata("username")==""){
/*new block added from */
$array = array ();
$name=$array ['name'] = $ads->getName();
$mobile=$array ['mobile'] = $ads->getMobile();
$array ['email'] =$ads->getEmail();
$array ['password'] = '12345';
$array ['dob'] = DateTime::createFromFormat ( "d/m/Y", '');
$array ['everified'] = 0;
$array ['mverified'] = 0;
$array ['devicetype'] = 0;
$array ['usertype'] = 0;
$user = new Entity\User ( $array );
$this->em->persist ( $user );
$this->em->flush (); //till this
$this->load->model ( 'homemodel' );
$randstr = $this->homemodel->rand_string ( $name, $mobile );
$this->load->model ( 'emailmodel' );
$email =$ads->getEmail();
$randstr = $this->emailmodel->getmailcode ( $email );
$this->emailmodel->sendVerificatinEmail ( $email, $randstr );
}
$this->view_data ['content'] = 'contents/adcreated';
$this->load->view ( 'templates/layout', $this->view_data );
} catch ( Exception $e ) {
$this->error ( "createAds(): creation faield." . $e->getMessage () );
$this->session->set_flashdata ( 'err_msg', "Failed to post ad" . $e->getMessage () );
$this->view_data ['content'] = 'contents/postads';
$this->load->view ( 'templates/layout', $this->view_data );
}
}
}
这是我的错误消息:
无法在第12行的C:\ wamp \ www \ rah \ application \ core \ JSONParserException.php中重新声明类JSONParserException