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 8517011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:34:58+00:00 2026-06-11T05:34:58+00:00

This is my first question here, so please try to be patient with me

  • 0

This is my first question here, so please try to be patient with me 🙂

I’ve stumbled upon a weird behavior populating an object.

I started to convert the objectQuery::create()-> ... ->find() methods used in my project to $c = new Criteria(), $c-> ... objectPeer::doSelect($c) since I’ve been told Queries shouldn’t be used when criteria can be.

I have a function, that returns all the prices of items from the shop. Or at least did. The thing that I cannot figure out is this:

the old code:

static public function shopGetPrices($id){

    $prices = itemPriceQuery::create()->
        addJoin(itemPricePeer::ITEM_ID, itemPeer::ID, Criteria::LEFT_JOIN)->
        addJoin(itemPeer::CATEGORY_ID, categoryPeer::ID, Criteria::LEFT_JOIN)->
        addJoin(categoryPeer::SHOP_ID, shopPeer::ID, Criteria::LEFT_JOIN)->
        add(shopPeer::ID, $id)->find();

    return $prices;
}

returns correctly populated PropelObjectCollection object, through which i can go with foreach, and get/set the itemPrice objects and attributes i need.

now, the new code:

static public function shopGetPrices($id){

    $c = new Criteria();
    $c->addJoin(itemPricePeer::ITEM_ID, itemPeer::ID, Criteria::LEFT_JOIN)->
        addJoin(itemPeer::CATEGORY_ID, categoryPeer::ID, Criteria::LEFT_JOIN)->
        addJoin(categoryPeer::SHOP_ID, shopPeer::ID, Criteria::LEFT_JOIN)->
        add(shopPeer::ID, $id);

    return self::DoSelect($c);
}

returns an array of itemPrice objects, but they are populated with item values related to itemPrice objects through join. that means : when I call print_r(self::DoSelect($c)); it prints

 Array
 (
  [0] => ItemPrice Object
    (
        [startCopy:protected] => 
        [id:protected] => 47 <- id of joined item
        [item_id:protected] => 9 <-foreign key to category object of joined item
        [price:protected] => 0 
        [unit:protected] => Axe <- name of item, not unit (unit is like 'golden', 'iron', 'wood' or whatever )
        [active:protected] => 
        [collItemsOrder:protected] => 
        [collItemsOrderPartial:protected] => 
        [alreadyInSave:protected] => 
        [alreadyInValidation:protected] => 
        [polozkyObjednavkasScheduledForDeletion:protected] => 
        [prisadyPolozkyObjednavkasScheduledForDeletion:protected] => 
        [validationFailures:protected] => Array()
        [_new:protected] => 
        [_deleted:protected] => 
        [modifiedColumns:protected] => Array()
        [virtualColumns:protected] => Array()

    )

[1] => ItemPrice Object
    (

…and so on.

There is probably some crucial difference between criteria and query object, that I’m missing. I searched on Google, StackOverflow, and who knows where, but I didn’t find anything resembling a solution to this.

This guy/gal had a vaguely similar problem, but I didn’t use addSelectColumn with my criteria, so it’s been another dead end for me.

Can anyone please point me in the right direction?

  • 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-06-11T05:35:00+00:00Added an answer on June 11, 2026 at 5:35 am

    I found the problem. It was that I had overriden method do select in itemPricePeer class

    public static function doSelect(Criteria $criteria, PropelPDO $con = null){
    
        $critcopy = clone $criteria;
        $critcopy->add(self::ACTIVE, 1);
    
        return self::populateObjects(itemPeer::doSelectStmt($critcopy, $con));
    
    }
    

    I switched self/itemPricePeer with itemPeer in populateObjects arguments. silly me :-/ Thanks for your responses anyway j0k.

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

Sidebar

Related Questions

this is my first question here so be gentle ! recently i try to
This is my first question here so try to make my best so you
Note 1: This is my first question here. Please be gentle. Note 2: Yes,
this is my first question here :) I know that I should not check
Ok, I need help. This is my first question here. Background: I am working
this is my first question in here, and I would like to ask if
this is my first question on here. The question is simple - # this
this is my first time asking a question here. I tried to be well
this is my first question.. so, here we go. i have a site, 100%
Sorry, this's my first time to ask a question here. So, I don't have

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.