Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select specific fields #217

Open
markdave27 opened this issue Jan 9, 2016 · 4 comments
Open

Select specific fields #217

markdave27 opened this issue Jan 9, 2016 · 4 comments

Comments

@markdave27
Copy link

Hi,

How can you return only selected fields using all get functions (get(), get_by(), get_many(), get_many_by() and get_all()). Fetching all the columns of the database/record is not that fast or ideal I believe. Though I can do a filtering of the returned object data but still the delay was already made during the query. I how you can give me an advice on how to make this happen. Thank you in advance.

@michail1982
Copy link

write method

public function select($what = '*', $escape = true) {
    $this->_database->select($what, $escape); return $this; 
}

usage

$this->article_model->select('id, title')->get_all();

@markdave27
Copy link
Author

Thanks for the suggestion michail1982, I'll take note of this and try it out. 👍

@thuc101
Copy link

thuc101 commented Aug 24, 2019

public function your_select(){ $this->db->select('id,field1,field2'); return $this; }

@thuc101
Copy link

thuc101 commented Aug 24, 2019

$this->article_model->your_select()->get_all();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants