-
Notifications
You must be signed in to change notification settings - Fork 96
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
Allow _select_ condition in related conditions. #272
Comments
You can't use the orm to do partial selects as this results in incomplete models. |
@itsash-- use the DB class to partially select data. (Excuse any syntax errors / poor code 😄) $fields = [
['parent.id', 'parent_id'],
['parent.name', 'parent_name'],
['child.id', 'child_id'],
['child.name', 'child_name']
];
$data = DB::select_array($fields)
->from('parent')
->join('child')->on('parent.child_id', '=', 'child.id')
->as_object()
->execute();
foreach($data as $d)
{
$str = $d->parent_id . '\n';
$str .= $d->parent_name . '\n';
$str .= $d->child_id . '\n';
$str .= $d->child_name . '\n';
print($str);
} |
This can't be done without massive refactoring of the Query class. So it has to move to 2.0 |
@stevewest : I understand this, but it's not for building orm models, instead to generate the SQL syntax for execution. @WanWizard: I was assuming the Orm was iterating over the related models' properties and appending them all to the select statement. It does work for the main Orm: |
@itsash-- My bad, lots of people have asked how to do partial selects with orm objects and thought you where wanting the same. Sorry for the misunderstanding. |
I have been attempting to use ORM to do the complex work, in order to build a nice query to execute in the DB class.
for example:
I was hoping to be able to do one of the following:
Or using the
select
define only those fields from the join; to give me only:t0_id, t1_name, t0_name
The text was updated successfully, but these errors were encountered: