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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:56:32+00:00 2026-05-26T11:56:32+00:00

I have an on-insert trigger that updates a product code in a table, based

  • 0

I have an on-insert trigger that updates a product code in a table, based on a customer’s most recent code, stored in another table.

With symfony and Propel, I am doing the following (truncated unnecessary fields)

// actions.class.php
$lineitem = new LineItem();
$lineitem->setCustomerId( $customerId );

$thisProduct = ProductPeer::cacheProduct($orderDetails);
$lineitem->setCode($thisProduct->getCode()); // this should be fetching and setting the auto_code, inserted from the trigger.
$lineitem->save();

The cacheProduct function (part of ProductPeer) below

// ProductPeer.php
// auto_code field in DB left blank, ready to be written to by the trigger
// cacheProduct function
public static function cacheProduct($orderDetails)
{
    $product = new Product();
    $product->setName( $orderDetails->getName() ); 
    $product->setCustomerCode( $orderDetails->getCustomerCode() );
    //$product->setCode(); // this will be set by the TRIGGER on insert.
    $product->save();

    return $product->getId();
}

So the problem is that the product is being inserted, and the trigger is being run successfully, but Symfony is never aware of the newly inserted ‘code’ value. Running a fresh ProductPeer::retrieveByPK() still shows an empty ‘code’ field.

So in essence, at all points, $lineitem->getCode() returns null.

I’ve tried wrapping this in transactions, but it shouldn’t be necessary … and also there is potential for this to be in a loop and I don’t want to open and close transactions repeatedly unless absolutely necessary.

1) When does a MYSQL trigger actually run … on $xxx->save()? At the end of the script?
2) How can I access this value post-trigger, while still in the same script?

Solution found, thank you 🙂
Working with Propel version 1.4.8 or greater

  • 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-26T11:56:33+00:00Added an answer on May 26, 2026 at 11:56 am

    Set

    reloadOnInsert="true"
    

    on your table schema, and rebuild your model: Example

    (Be aware that this may have been introduced in a more recent version of Propel – check the version of your Propel plugin.)

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

Sidebar

Related Questions

I have a table that has an insert trigger on it. If I insert
I have a trigger that executes a function on table insert or update. It
HI, I have an insert statement in a Stored Procedure that requires the value
I have a trigger that gets inserts and updates to a view. I need
I have just written a stored procedure and stored function that serve to insert
I have a table Product and another table ProductLog . The log table needs
I am maintaining some code that has a trigger on a table to increment
I have a view that has an INSTEAD OF INSERT trigger (in SQL Server
This is what I currently have: CREATE OR REPLACE TRIGGER MYTRIGGER AFTER INSERT ON
I have an INSERT query that is pulling data from two tables and inserting

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.