Doctrine single-Table operations

Source: Internet
Author: User
// ================================================ ================================================== Add data to the table member as the table name
/*
$ Ins_vote_answer = new voteanswer (); // insert data to the vote_answer table
$ 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 ();
*/

// ================================================ ============================== Query data
/*
$ 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'); // === query method 1 Table Name vote_answer
$ Que_voteanswer = doctrine_query: Create ()-> select ('Id, member_id ')-> from ('voteanswer')-> where ('Id = 2 ') -> andwhere ('Member _ id = 1')-> orderby ('id')-> groupby ('id'); // === method 2
$ Row_voteanswer = $ que_voteanswer-> fetchone (); // This method gets only the first record of the result set no matter how many times it is executed
// $ Row_voteanswers = $ que_voteanswer-> execute (); // It is basically the same as the following fetcharray () method and needs to be extracted.
// $ Row_voteanswers = $ que_voteanswer-> fetcharray ();
// Foreach ($ row_voteanswers as $ row_voteanswer ){
$ This-> A = $ row_voteanswer ['id'];
//}
*/
// ================================================ ============================== Update
/*
$ 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); // === method 1 Table Name vote_answer
// $ Que_voteanswer = doctrine_query: Create ()-> Update ('voteanswer')-> set ('Member _ id', 1)-> set ('body ', 1)-> where ('Id = 3')-> andwhere ('Member _ id = 2'); // === method 2
$ Row_voteanswers = $ que_voteanswer-> execute (); // Execute
*/

// ================================================ ================================ Delete
/*
$ Id = 4;
$ Member_id = 1;
$ Que_voteanswer = doctrine: gettable ('voteanswer')-> createquery ()-> Delete ('voteanswer')-> where ('Id =? ', $ Id)-> andwhere ('Member _ id =? ', $ Member_id); // === method 1 Table Name vote_answer
// $ Que_voteanswer = doctrine_query: Create ()-> Delete ('voteanswer')-> where ('Id = 2 ') -> andwhere ('Member _ id = 2'); // === method 2
$ Row_voteanswers = $ que_voteanswer-> execute (); // Execute
*/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.