ホームページ >データベース >mysql チュートリアル >Doctrine单表操作_MySQL
bitsCN.com
1 //====================================================================往表中增加数据vote_answer为表名<br> 2 /*<br> 3 $ins_vote_answer = new voteAnswer();//往vote_answer表中插入数据<br> 4 $ins_vote_answer['id'] = 3;<br> 5 $ins_vote_answer['member_id'] = 1;<br> 6 $ins_vote_answer['vote_question_id'] = 1;<br> 7 $ins_vote_answer['vote_question_option_id'] = 1;<br> 8 $ins_vote_answer['body'] = 1;<br> 9 $ins_vote_answer['created_at'] = 1;<br>10 $ins_vote_answer['updated_at'] = 1;<br>11 $ins_vote_answer->save();<br>12 */<br>13 <br>14 //====================================================================查询数据<br>15 /*<br>16 // $id = 1;<br>17 // $member_id = 1;<br>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<br>19 // $que_voteAnswer = Doctrine_Query::create()->select('id,member_id')->from('voteAnswer')->where('id = 2')->andWhere('member_id = 1')->orderBy('id')->groupBy('id');//====查询方法二<br>20 // $row_voteAnswer = $que_voteAnswer->fetchOne();//不管执行几次此方法只获取结果集第一条记录<br>21 // //$row_voteAnswers = $que_voteAnswer->execute();//和下面的fetchArray()方法基本等同,都需要沥遍<br>22 // //$row_voteAnswers = $que_voteAnswer->fetchArray();<br>23 // //foreach($row_voteAnswers as $row_voteAnswer){<br>24 // $this->a = $row_voteAnswer['id'];<br>25 // /