-
Notifications
You must be signed in to change notification settings - Fork 51
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
Two different arrays for relational models #16
Comments
Hi @rupalgohel,
// Find the active records whose primary key value is 10, 11 or 12.
$activeRecords = $this->Model->findAll([10, 11, 12]);
// Find the active recordd whose type is 'A' and whose status is 1
$activeRecords = $this->Model->findAll(['type' => 'A', 'status' => 1]);
// Query builder ORM usage
$this->Model->find()->where_in('id', [10, 11, 12]);
$activeRecords = $this->Model->findAll();
// Print all properties for each active record from array
foreach ($activeRecords as $activeRecord) {
print_r($activeRecord->toArray());
} |
Hii @yidas , Thanks for quick reply.
as per your method I will get one array at at time. |
Hi @rupalgohel ,
and then use it like this
|
Hi @rupalgohel, You can also describe how Yii2 query the model array data with relational data, I will check it out. |
Another way to get relational data without override: $activeRecord = $this->Model->findOne(123);
$activeRecord->relationName = $activeRecord->relationName;
print_r($activeRecord->toArray()); |
@razorsharpshady, thanks for your suggestion. @yidas , as per your suggested code, what if I want all the active records with relational model. Yes we can also implement the way Yii2 gives like
This will give output as I mention above without use of for loop or someother. |
Hi @rupalgohel, Good point! Thank for your advice. |
Thanks for consideration @yidas. I will use this in my new CI projects. |
@yidas , I am waiting for this. |
@yidas , any update? |
@yidas, I am waiting for this too |
Dear @yidas any update for eager loading? Maybe this will help: |
Hi~ It seems that I was developing this before, but then I thought that there are not many users of this package now: If anyone else is eager for this feature, please star this project and you could also comment here to let me know~ Thank you for your support! |
I am getting two different arrays for relational model.
Like Model - 1:
[_readProperties:yidas\Model:private] => Array
(
[id] => 1
[value] => 545488
[data] => 1
)
with this $vendors = $model->vendors; I am getting another data.
Here model 1 hasOne relation with vendor table.
My requirement and yii2 also gives relational query data in single array
(
[id] => 1
[value] => 545488
[data] => 1
[verndor] => ()
)
and how to get array of query $model = $this->Vendor_model->findAll();
The text was updated successfully, but these errors were encountered: