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

More configurations for get #8

Open
cgarvisacmg opened this issue May 18, 2011 · 6 comments
Open

More configurations for get #8

cgarvisacmg opened this issue May 18, 2011 · 6 comments

Comments

@cgarvisacmg
Copy link

It would be nice to pass conditions to the get.

Like if I wanted to get the latest created user:

Phactory::get('user', array('name' => 'testuser'), array(
    'order' => 'id DESC', 
    'limit' => 1,
);
@jimbojsb
Copy link
Collaborator

Phactory is always accepting pull requests :)

Nevertheless, I agree, this sounds like a good idea in general. I'd be interested to hear the case where it's necessary.

@jblotus
Copy link

jblotus commented Jun 11, 2011

How many records are you testing at once to need that type of ordering/limiting? Usually on a unit test level, you wont have too many records to pull up and you should be truncating records and resetting Phactory per test.

Not that I disagree with the idea of adding conditions.

@cgarvis
Copy link
Contributor

cgarvis commented Jun 13, 2011

I have a table that is kind of a log. It contains information that a customer service rep can see to know what the system has done on behalf of the customer. In my unit testing I've had code inserting multiple comments. What I would like to be able to do is pull the last comment. We have the ability to pull the first one but not the last. That is why having the ability to set the order and limit for the Phactory::get() would be useful.

@jblotus
Copy link

jblotus commented Jun 13, 2011

are you using Phactory to insert the comments? If so you can specify an id and reference that in your get();

Phactory::create('comment', array('id' => 12345, 'data' => 'some comments'));

Phactory::get('comment', array('id' => 12345));

@cgarvis
Copy link
Contributor

cgarvis commented Jun 13, 2011

When I use Phactory to create records, I do this. But this case is when the code creates those records. I have no way of knowing the id.

@jblotus
Copy link

jblotus commented Jun 13, 2011

Understood. Maybe a patch would be in order.

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

4 participants