我有两个表“登录”和“个人资料”。login table
包含user_id, username, password, type
. profile table
包含profile_id, user_id, name, address, phone_no,email,status,pancardno,gender,birthday,joiingdate,endingdate
. 在这里我使用user_id
.Formreference key
包含用户名、密码、类型、姓名、地址、电话号码。那么如何在 Zend Framework 的配置文件表中插入用户名、密码、输入“登录”表和其他字段。
这是我的控制器代码。
include_once(APPLICATION_PATH.'/modules/admin/models/DbTable/Login.php');
public function emppostAction()
{
$session=new Zend_Session_Namespace();
if(isset($session->id))
{
$this->view->name="<b>".$session->name."</b>";
$this->render('employee');$data= new Model_DbTable_Login(); if($this->getRequest()->isPost()) { $un=$this->getRequest()->getPost('un'); $name=$this->getRequest()->getPost('name'); $bday=$this->getRequest()->getPost('bday'); $bmnth=$this->getRequest()->getPost('bmonth'); $byear=$this->getRequest()->getPost('byear'); $bdate=$byear."-".$bmnth."-".$bday; $jday=$this->getRequest()->getPost('jday'); $jmnth=$this->getRequest()->getPost('jmonth'); $jyear=$this->getRequest()->getPost('jyear'); $jdate=$jyear."-".$jmnth."-".$jday; $eday=$this->getRequest()->getPost('eday'); $emnth=$this->getRequest()->getPost('emonth'); $eyear=$this->getRequest()->getPost('eyear'); $edate=$eyear."-".$emnth."-".$eday; $phoneno=$this->getRequest()->getPost('phoneno'); $add=$this->getRequest()->getPost('add'); $qf=$this->getRequest()->getPost('qf'); $jod=$this->getRequest()->getPost('jod'); $email=$this->getRequest()->getPost('email'); $pwd=$this->getRequest()->getPost('pwd'); $gn=$this->getRequest()->getPost('gender'); $ms=$this->getRequest()->getPost('ms'); $desg=$this->getRequest()->getPost('desig'); $status=$this->getRequest()->getPost('status'); $pan=$this->getRequest()->getPost('pancard'); $insert=$data-> >insertData($un,$pwd$name,$bdate,$phoneno,$add,$qf,$jdate,$edate,$gn,$ms,$desg,$email,$pan,>$status); $this->_helper->redirector('viewemp', 'Leave'); exit; } } else { $this->_helper->redirector('login','index'); }
}
在模型中我有
类 Model_DbTable_Login 扩展 Zend_Db_Table_Abstract
{
公共函数 insertData($un,$pwd){
$data = array(
'用户名'=> $un,
'密码'=> $pwd
);
$data2 = array( 'name'=> $name, 'birthdate'=> $bdate, 'phoneno'=> $phoneno, 'address'=> $add, 'qualification'=> $qf, 'joiningdate'=> $jdate, 'endingdate'=> $edate, 'gender'=> $gn, 'maritalstatus'=> $ms, 'designation'=> $desg, 'email'=> $email, 'pancardno'=>$pan , '状态'=> $状态 );try{ //here i m inserting data in login table. $result=$this->insert($data); // now here i want to insert data in profile table $profile=$this->insert($data2) }
捕获(异常 $e){
echo "
".$e;exit;
}
}
那么如何在登录表中插入数据的同时在profile表中插入数据呢?