Comments (7)
Initially, we were considering using PHP's ArrayObject for a collection returned form the database, but we decided not to because of the overhead involved. If someone wanted to provide some benchmarks that shows a large performance hit is not incurred when using ArrayObject, then we could implement the feature.
from php-activerecord.
I think this would provide a lot of flexibility. See my hack there: https://github.com/greut/php-activerecord/blob/relation_count/lib/Relationship.php#L453-470
from php-activerecord.
Can you please go through this?
Cheers,
from php-activerecord.
What about this?
<?php
class Person extends ActiveRecord\Model
{
static $has_many = array(
array('addresses')
);
}
$person = Person::find(1);
// all the addresses, no hit on the DB. (obj1)
$addresses = $person->addresses;
// the last five addresses, no hit on the DB (obj2)
$addresses = $addresses(array('limit' => 5, 'order' => 'id desc'));
// hits the DB and cache the result
var_dump($addresses[0]);
obj1
and obj2
are two different objects, so calling it results in creating a modified copy.
from php-activerecord.
little resurrection .
Could this be merged into master ?
This will greatly benefit, in all poly relations.
If there are anything thats missing, before it can be merged, I'll try to find the time to finish it.
Btw, would it be possible to implement it same as ruby with .. find / where on the collection ?
from php-activerecord.
@nakashu See #108, which introduces a fix for this. We're looking at pulling it into v1.1 ATM. Thanks for the ping!
from php-activerecord.
closing in favor of #376
from php-activerecord.
Related Issues (20)
- array_column not working for relations
- index not of right type after row creation
- Model::all() phpdoc typehint: @returns array in stead of @returns static[]
- count(): Parameter must be an array or an object that implements Countable in ActiveRecord\Model::find_by_pk() (line 1670 of php-activerecord/lib/Model.php) HOT 9
- 1.x not working with sqlite HOT 3
- PHP Active Record website is out of service! HOT 9
- Relations
- Website down HOT 8
- what system to migrate to? HOT 2
- Using "through" with find('all')
- I want to continue the project as a new repo HOT 2
- Use githubpages [suggestion]
- validates_length_of does not support multibyte strings (e.g., utf8)
- php-activerecord 1.2 HOT 1
- php-activerecord SSL (MariaDB / MySQL) HOT 1
- php-activerecord php 8.0 HOT 3
- use of hash (#) in mysql passwords affecting connection url parsing.
- Using 2 or more schemas in a same connection
- save or retrieve datetime with milliseconds
- Can we assume this has been abandoned? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-activerecord.