Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6627609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:02:03+00:00 2026-05-25T22:02:03+00:00

I am currently learning to use the Propel ORM, and I want to reuse

  • 0

I am currently learning to use the Propel ORM, and I want to reuse a critera for two slightly different queries:

$criteria = ArticleQuery::create()
        ->filterByIsPublished(true)
        ->orderByPublishFrom(Criteria::DESC)
        ->joinWith('Article.Author')
        ->keepQuery();

$this->news = $criteria
        ->filterByType('news')
        ->find();
$this->articles = $critera
        ->filterByType('article')
        ->find();

However, this won’t work as expected, because now the query for articles will try to find entries where the type is both ‘news’ and ‘article’, which of course is impossible.

So we need to get a clone of this object, and what seemed intuitive to me was to simply add the clone keyword inside paranthesis:

$this->news = (clone $criteria)
        ->filterByType('news')
        ->find();

Parse error: syntax error, unexpected T_OBJECT_OPERATOR

Instead we have to assign it to a variable before we can use it:

$clonedCritera = clone $criteria;
$this->news = $clonedCriteria
        ->filterByType('news')
        ->find();

You have the same behaviour with the newoperator. I see the propel developers have circumvented this limitation by replacing:
new ArticleQuery()->doOperations() with ArticleQuery::create()->doOperations().

Why did the PHP language designers choose to do it this way? If you could use the result of these expressions directly, it would make the code more fluent and, in some cases, easier to read.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:02:03+00:00Added an answer on May 25, 2026 at 10:02 pm

    Why must we assign a clone to a new variable?

    Unfortunately, the answer is that the developers haven’t gotten around to supporting direct dereferencing on objects returned via clone yet.

    In PHP 4, you couldn’t “dereference” any objects returned by method. You had to assign it to a dummy variable first.

    In the next version of PHP, array dereferencing is to be supported.

    So, it’s clear that the dev team incrementally adds such features on their timetable.

    The best I can tell you is to request this functionality from the dev team.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently learning on how to use the Python optparse module. I'm trying the
I am currently learning the zsh and now I wanted to use strftime but
I currently learning about scrum and want to learn from experienced professionals in the
i am currently learning Zend Framework 1.10 and intend to use Doctrine 2. however
I'm currently learning to use MasterPages and ContentPlaceHolders in ASP.NET 3.5 and C# -
As I'm currently learning to use WCF Services, I am constantly encountering tutorials on
Im very new to Objective-C and am currently learning how to use Xcode and
I am currently learning about these maps. Now I would like to create a
Hey. I'm currently learning to use MySql and have a couple of questions. 1)
I am currently learning to use Springy which is a force directed graph layout

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.