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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:35:46+00:00 2026-05-30T19:35:46+00:00

I am trying to do what I thought would be a trivial task using

  • 0

I am trying to do what I thought would be a trivial task using Symfony 1.4 with the propel ORM. I’ve got a custom static class setup that I would like to use to return the id of a row by searching the name of the item.

Here’s my function:

static public function getItemIdByName ( $name )
{
    $criteria = new Criteria();
    $criteria-> clearSelectColumns();
    $criteria -> add (ItemsPeer::ITEM_NAME, $name, Criteria::LIKE );
    $criteria -> addSelectColumn(ItemsPeer::ITEM_ID);
    $criteria -> setLimit (1);

    $itemID = ItemsPeer::doSelect( $criteria );

    return $itemID;
}

Now when I return $itemID, I get the name of the item. However, I cannot get the item_id column at all. I’ve tried returning $itemID[1] and several other column indexes, but it says those do not exist. If I print_r($itemID), I see an array of every column in that table, the only two with values are item_id and item_name. However, I still can’t find a way to return or access that variable.

Any suggestions?

  • 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-30T19:35:47+00:00Added an answer on May 30, 2026 at 7:35 pm

    I think that the error is in position of clearSelectColumns, but I can mistaken. Try to use doSelectStmt instead of doSelect:

    $c = new Criteria();
    $c->add(ItemsPeer::ITEM_NAME, $name, Criteria::LIKE);
    $c->clearSelectColumns();
    $c->addSelectColumn(ItemsPeer::ITEM_ID);
    $c->setLimit(1);
    
    $stmt = ItemsPeer::doSelectStmt($c);
    return $stmt->fetch(PDO::FETCH_COLUMN); // $itemID
    

    This should solve your problems. However, if you are using sf 1.4 and Propel >= 1.5, I’d suggest you to use Propel Query:

    return ItemsQuery::create()
      ->filterByItemName($name . '%')
      ->select('ItemId')
      ->findOne();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to get my head around XAML and thought that I would
I'm new to git and trying to do what I thought would be trivial.
I'm trying to write (what I thought would be) a simple bash script that
Im trying to do something that I originally thought would be quite simple, but
I am trying to do something that I thought would be very easy with
I'm trying to do something that I thought would be quite simple but as
I am trying to do something I thought would be simple. I have a
I'm trying to do something which I thought would be fairly simple. Get IIS
I am trying to Emit what I thought would be a simple object array
I'm trying to do something that I thought ought to be reasonably simple but

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.