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

Fetch only specific fields instead of all #17

Closed
jschreuder opened this issue Apr 25, 2011 · 5 comments
Closed

Fetch only specific fields instead of all #17

jschreuder opened this issue Apr 25, 2011 · 5 comments
Labels
Milestone

Comments

@jschreuder
Copy link
Contributor

Should be possible in 2 ways:

$query->select('name', 'city'); // only select name & city
$query->select(array('last_name' => false)); // selects every column except "last_name"

When a model is gotten like this all other fields will not be available.

First thoughts:

  • Primary key(s) must be gotten, won't be optional
  • How to deal with foreign keys for BelongsTo? (probably not optional as well)
  • Checking which properties are available in __set()/__get() can't use Model::properties() anymore
  • Saving/updating should ignore fields that aren't there
  • New objects should add all non defined fields though, maybe from the beginning.
@patie
Copy link

patie commented May 16, 2011

what about 'select' => array('name', 'city') in find?

example:

Model_User::find('first', array(
                'select' => array( 'name', 'city' ),
                'where' => array(
                    array( 'active', '=', 1 ),
                ),
            ));

its only idea.. is not necessarily

@jschreuder
Copy link
Contributor Author

Everything Orm::Query::select() can do, can also be done by the array usage from the Model::find() method.

@patie
Copy link

patie commented May 16, 2011

wow!

@DregondRahl
Copy link

selecting specific fields, may make the code longer especially with relationships. maybe create a skip() method ?

->skip(array('user.password', 'list.content'));

@jschreuder
Copy link
Contributor Author

Try reading the original proposal before suggesting something that's already there.

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

No branches or pull requests

4 participants