开发者

Yii how to retrieve a row, delete and insert a new row in another table

开发者 https://www.devze.com 2023-03-25 21:44 出处:网络
开发者_运维百科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...

开发者_运维百科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.

0

精彩评论

暂无评论...
验证码 换一张
取 消