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

  • SEARCH
  • Home
  • 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 3975032
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:38:14+00:00 2026-05-20T04:38:14+00:00

ZF 1.9.5 here. Someone suggested catching exceptions to emulate ON DUPLICATE KEY UPDATE when

  • 0

ZF 1.9.5 here. Someone suggested catching exceptions to emulate ON DUPLICATE KEY UPDATE when using Zend_Db_Table.

Currently, I’m getting

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'i7dd30253497cfc0539d7c5830a926f7d' for key 'ukey'

..when using

$orderRow = $this->createRow();
$orderRow->ukey = $ukey;
$orderRow->save();

So, I want to catch that bugger with try / catch. On exception update , else insert.
But I don’t know what to catch. Zend_Db_Exception? PDOException? Zend_Db_Adapter_Exception? I’ve tried several, but I don’t think I got it.


Later edit.
This worked for me:

        try {
            $orderRow = $this->createRow();
            $orderRow->ukey = $ukey;
            $orderRow->$stepCol = time();
            $orderRow->save();
        } catch (Zend_Db_Statement_Exception $e) {
            // on UNIQUE error, update
            if ($e->getCode() == 23000) {
                $orderRow = $this->fetchRow($this->select()->where('ukey = ?', $ukey));
                $orderRow->$stepCol = time();
                $orderRow->save();
            }
        }
  • 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-20T04:38:14+00:00Added an answer on May 20, 2026 at 4:38 am

    Just look what exception is getting thrown like this:

    try {
        // query
    } catch (Exception $e) {
        var_dump(get_class($e));
    }
    

    That should tell you what kind of exception you need to catch because “Exception” will catch every type of exception, be it a ZF exception or a PDO exception or something completely different

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

Sidebar

Related Questions

As someone here pointed me out, for getting the max duplicated item in a
I hope someone here can help me.. I am currently having a small issue
So someone suggested using a WPF TreeView , and I thought: Yeah, that seems
Hopefully someone here can help me! I'm trying to set up fancybox so when
Has someone here ever had experience with the D programming language ? It seems
I'm hoping someone here can answer these definitively: Does putting a VHD file in
I'm hoping I'm doing something wrong here and someone can point me in the
I am a Java beginner and I would appreciate it if someone here can
I'm staring blank on this error, so I hope someone here can point out
So, I'm looking through a java library (JScience) after someone here thoughfully pointed me

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.