如何将其转换为codeigniter查询样式?

时间:2016-05-13 06:31:49

标签: php codeigniter-3

 SELECT `users`.`first_name`, `user_profile`.`user_id`, 
`user_profile`.`image`, `messages`.* FROM `messages` LEFT JOIN `user_profile` ON 
`user_profile`.`user_id` = `messages`.`from_id` LEFT JOIN `users`ON `users`.`id` 
= `messages`.`from_id`  WHERE (messages.delete_from != '9' AND messages.delete_to 
!='9’)  AND ( `messages`.`members` = '4,9' OR `messages`.`members` = '9,4' ) 
ORDER BY `date` ASC

1 个答案:

答案 0 :(得分:0)

Usage: rails_best_practices [options]
    -d, --debug                      Debug mode
    -f, --format FORMAT              output format
        --without-color              only output plain text without color
        --with-textmate              open file by textmate in html format
        --with-sublime               open file by sublime in html format (requires https://github.com/asuth/subl-handler)
        --with-mvim                  open file by mvim in html format
        --with-github GITHUB_NAME    open file on github in html format. GITHUB_NAME is like railsbp/rails-bestpractices OR full URL to GitHub:FI repo
        --with-hg                    display hg commit and username, only support html format
        --with-git                   display git commit and username, only support html format
        --template TEMPLATE          customize erb template
        --output-file OUTPUT_FILE    output html file for the analyzing result
        --silent                     silent mode
        --vendor                     include vendor files
        --spec                       include spec files
        --test                       include test files
        --features                   include features files
    -x, --exclude PATTERNS           Don't analyze files matching a pattern
                                     (comma-separated regexp list)
    -o, --only PATTERNS              analyze files only matching a pattern
                                     (comma-separated regexp list)
    -g, --generate                   Generate configuration yaml
    -v, --version                    Show this version
    -h, --help                       Show this message

使用$this->db->from($this->table); $this->db->select('users.first_name,user_profile.user_id,user_profile.image,messages.*'); $this->db->join('user_profile', 'user_profile.user_id = messages.from_id','left'); $this->db->join('users', 'users.id = messages.from_id','left'); $this->db->where($id1); $this->db->where($id2); $this->db->group_start(); $this->db->where('messages.members',$con1); $this->db->or_where('messages.members',$con2); $this->db->group_end(); $this->db->order_by('date','asc'); $this->db->group_start();作为括号