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

Create queryBuilder from parts. #556

Closed
wants to merge 3 commits into from
Closed

Create queryBuilder from parts. #556

wants to merge 3 commits into from

Conversation

NoUseFreak
Copy link
Contributor

Add a feature that can create a queryBuilder from queryBuilder parts.

This can be used when a query is build and needs to be stored somehow and restore it later.

@doctrinebot
Copy link

Hello,

thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:

http://doctrine-project.org/jira/browse/DDC-2258

@Majkl578
Copy link
Contributor

👎 This shouldn't pollute EntityManager's public API. QueryBuilder::setDQLParts() would be more appropriate, but still, there is QueryBuilder::add() method.

@NoUseFreak
Copy link
Contributor Author

@jmikola Just adding every part from getDQLParts won't work. This makes rebuilding a querybuilder hard.

{
if ($part) {
if (is_array($part) && $name != 'join') {
$part = current($part);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be reset ?

@NoUseFreak
Copy link
Contributor Author

I moved it to the correct place, updated tests and applied coding standards.

@jmikola
Copy link
Member

jmikola commented Jan 28, 2013

@NoUseFreak: Why did you tag me in this issue? Did you mean to respond to @Majkl578?

@NoUseFreak
Copy link
Contributor Author

@jmikola I indeed ment @Majkl578 but the autocomplete apparently didn't go as planned.

@NoUseFreak
Copy link
Contributor Author

ping

@beberlei
Copy link
Member

@NoUseFreak why don't you do $qb2 = clone $qb;? Does the same thing

@beberlei
Copy link
Member

beberlei commented May 4, 2013

I don't think we want this feature, if you need to store a query you can store DQL instead.

@beberlei beberlei closed this May 4, 2013
@L0rD59
Copy link

L0rD59 commented Oct 17, 2013

Hey ! i need this feature too

Where i can find it ?

@stof
Copy link
Member

stof commented Oct 17, 2013

@L0rD59 this PR has been rejected. See the 2 comments from @beberlei just above

@guilhermeblanco
Copy link
Member

@L0rD59 You can easily achieve it:

$qb_new = clone $qb;

@L0rD59
Copy link

L0rD59 commented Oct 17, 2013

thx for replies,

In detail, i use Lexik FormFilter Bundle and PagerFanta Bundle

and i mix both

so i want persist the QB of Lexik when changing page. I use session for that

but the QB Builder object can't persist in session, so i decide to persist QB->getParts()

I can too persist QB->getDQL()

Next, i need to transform QB->getParts() (or QB->getDQL()) to QB for PagerFanta bundle

thx for your times.

@stof
Copy link
Member

stof commented Oct 17, 2013

@L0rD59 Pagerfanta does not require you to use a query builder. It is able to paginate a Query object (actually, it only paginates Query objects as the first action done when using a QueryBuilder is doing a $query = $builder->getQuery()). And to build the Query object, the DQL is what you need

@L0rD59
Copy link

L0rD59 commented Oct 18, 2013

@stof thx !

it's work with Query !

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

Successfully merging this pull request may close these issues.

None yet

9 participants