Doctrine单表操作

//====================================================================往表中增加数据Member为表名
/*

$ins_vote_answer = new voteAnswer();//往vote_answer表中插入数据
$ins_vote_answer['id'] = 3;
$ins_vote_answer['member_id'] = 1;
$ins_vote_answer['vote_question_id'] = 1;
$ins_vote_answer['vote_question_option_id'] = 1;
$ins_vote_answer['body'] = 1;
$ins_vote_answer['created_at'] = 1;
$ins_vote_answer['updated_at'] = 1;
$ins_vote_answer->save();
*/

//====================================================================查询数据
/*

$id = 1;
$member_id = 1;
$que_voteAnswer = Doctrine::getTable('voteAnswer')->createQuery()->select('id,member_id')->where('id=?',$id)->andWhere('member_id=?',$member_id)->orderBy('id')->groupBy('id');//====查询方法一表名vote_answer
$que_voteAnswer = Doctrine_Query::create()->select('id,member_id')->from('voteAnswer')->where('id = 2')->andWhere('member_id = 1')->orderBy('id')->groupBy('id');//====查询方法二
$row_voteAnswer = $que_voteAnswer->fetchOne();//不管执行几次此方法只获取结果集第一条记录
//$row_voteAnswers = $que_voteAnswer->execute();//和下面的fetchArray()方法基本等同,都需要沥遍
//$row_voteAnswers = $que_voteAnswer->fetchArray();
//foreach($row_voteAnswers as $row_voteAnswer){
$this->a = $row_voteAnswer['id'];
//}
*/
//====================================================================更新
/*

$id = 3;
$member_id = 1;
$que_voteAnswer = Doctrine::getTable('voteAnswer')->createQuery()->update('voteAnswer')->set('member_id',2)->set('body',2)->where('id=?',$id)->andWhere('member_id=?',$member_id);//====方法一表名vote_answer
//$que_voteAnswer = Doctrine_Query::create()->update('voteAnswer')->set('member_id',1)->set('body',1)->where('id = 3')->andWhere('member_id = 2');//====方法二
$row_voteAnswers = $que_voteAnswer->execute();//执行
*/

//====================================================================删除
/*

$id = 4;
$member_id = 1;
$que_voteAnswer = Doctrine::getTable('voteAnswer')->createQuery()->delete('voteAnswer')->where('id=?',$id)->andWhere('member_id=?',$member_id);//====方法一表名vote_answer
//$que_voteAnswer = Doctrine_Query::create()->delete('voteAnswer')->where('id = 2')->andWhere('member_id = 2');//====方法二
$row_voteAnswers = $que_voteAnswer->execute();//执行
*/
posted @ 2011-11-08 22:24  风吹屁股凉冰冰  阅读(417)  评论(0编辑  收藏  举报