Doctrine单表操作

来源:互联网 时间:1970-01-01

 1 //====================================================================往表中增加数据vote_answer为表名

2 /*

3 $ins_vote_answer = new voteAnswer();//往vote_answer表中插入数据

4 $ins_vote_answer['id'] = 3; 5 $ins_vote_answer['member_id'] = 1;
6 $ins_vote_answer['vote_question_id'] = 1;
7 $ins_vote_answer['vote_question_option_id'] = 1;
8 $ins_vote_answer['body'] = 1;
9 $ins_vote_answer['created_at'] = 1;
10 $ins_vote_answer['updated_at'] = 1;
11 $ins_vote_answer->save();
12 */
13
14 //====================================================================查询数据
15 /*
16 // $id = 1;
17 // $member_id = 1;
18 // $que_voteAnswer = Doctrine::getTable('voteAnswer')->createQuery()->select('id,member_id')->where('id=?',$id)->andWhere('member_id=?',$member_id)->orderBy('id')->groupBy('id');//====查询方法一表名vote_answer
19 // $que_voteAnswer = Doctrine_Query::create()->select('id,member_id')->from('voteAnswer')->where('id = 2')->andWhere('member_id = 1')->orderBy('id')->groupBy('id');//====查询方法二
20 // $row_voteAnswer = $que_voteAnswer->fetchOne();//不管执行几次此方法只获取结果集第一条记录
21 // //$row_voteAnswers = $que_voteAnswer->execute();//和下面的fetchArray()方法基本等同,都需要沥遍
22 // //$row_voteAnswers = $que_voteAnswer->fetchArray();
23 // //foreach($row_voteAnswers as $row_voteAnswer){
24 // $this->a = $row_voteAnswer['id'];
25 // //}
26 */
27 //====================================================================更新
28 /*
29 // $id = 1;
30 // $member_id = 1;
31 // //$que_voteAnswer = Doctrine::getTable('voteAnswer')->createQuery()->select('id,member_id')->where('id=?',$id)->andWhere('member_id=?',$member_id)->orderBy('id')->groupBy('id');//====方法一表名vote_answer
32 // $que_voteAnswer = Doctrine_Query::create()->select('id,member_id')->from('voteAnswer')->where('id = 2')->andWhere('member_id = 1')->orderBy('id')->groupBy('id');//====方法二
33 // $row_voteAnswer = $que_voteAnswer->fetchOne();//不管执行几次此方法只获取结果集第一条记录
34 // //$row_voteAnswers = $que_voteAnswer->execute();//和下面的fetchArray()方法基本等同,都需要沥遍
35 // //$row_voteAnswers = $que_voteAnswer->fetchArray();
36 // //foreach($row_voteAnswers as $row_voteAnswer){
37 // $row_voteAnswer['member_id'] = 2;
38 // $row_voteAnswer->save();
39 // //}
40 */
41
42 //====================================================================删除
43 /*
44 // $id = 1;
45 // $member_id = 1;
46 // //$que_voteAnswer = Doctrine::getTable('voteAnswer')->createQuery()->select('id,member_id')->where('id=?',$id)->andWhere('member_id=?',$member_id)->orderBy('id')->groupBy('id');//====方法一表名vote_answer
47 // $que_voteAnswer = Doctrine_Query::create()->select('id,member_id')->from('voteAnswer')->where('id = 1')->andWhere('member_id = 1')->orderBy('id')->groupBy('id');//====方法二
48 // $row_voteAnswer = $que_voteAnswer->fetchOne();//不管执行几次此方法只获取结果集第一条记录
49 // //$row_voteAnswers = $que_voteAnswer->execute();//和下面的fetchArray()方法基本等同,都需要沥遍
50 // //$row_voteAnswers = $que_voteAnswer->fetchArray();
51 // //foreach($row_voteAnswers as $row_voteAnswer){
52 // $row_voteAnswer->delete();
53 // //}
54 */


相关阅读:
Top