开发者_运维百科How do you retrieve a row, delete and insert a new row in another table with Yii framework? Below is what I have so far...
$users=Entrepreneur_temp::model()->find('email=?', array($email));
$model->setAttributes($users);
if(isset($users)){
$model=new Entrepreneur;
$model->attributes = $users;
if($model->save()){
echo "true";
}else{
echo "error a";
}
}else{
echo "error";
}
I think you are doing something that's ideal, but to answer your question:
In your AR class, add a member called $tableName, then override tableName(), to return your new varialbe. You can then do something like:
$user = User::model()->findByPk(1);
$user->tableName = 'other_table';
$user->save();
(a setter for table name would be better)
I have not tested this, but I can't see any reason why it would not work.
精彩评论