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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:03:34+00:00 2026-06-06T04:03:34+00:00

I decided to have a go at PDO. The function below should move a

  • 0

I decided to have a go at PDO. The function below should move a row in a table to another database (from staging to production) and then delete the row in staging. It is 2 completely seperated databases.

I am able to get the row and insert it into the production database, but it does not delete the row in the staging database and gives me an error saying incorrect field name 343 which is the id of the row, I am not sure why it thinks it’s a fieldname where it is infact the value.

Please also feel free to give me better best practises. I don’t see my code as elegant and assume that there are better ways to do this, esspecially with the exceptions

 private function moveCallToProduction() {
    try {
        $array = array(":id" => $this->call['info']['call_id']);
        $sql = "SELECT * FROM `calls` WHERE `id`=:id";
        $query = $this->staging->prepare($sql);
        $query->execute($array);
        $row = $query->fetch(PDO::FETCH_NUM);
        try {
            $sql = "INSERT INTO `calls` (`id`,`sip_id`,`extension`,`caller_id`,`stage`,`status`,`survey_id`,`start`,`answer`,`hangup`) VALUES (`?`,`?`,`?`,`?`,`?`,`?`,`?`,`?`,`?`,`?`)";
            $stmt = $this->production->prepare($sql);
            $stmt->execute($row);
            if(!$stmt) {
                throw new Exception('Unable to move the call '.$this->call['info']['call_id'].' to the production server.');
            } else {
                try {
                    $sql = "DELETE FROM `calls` WHERE `id`='".$this->call['info']['call_id']."'";
                    $query = $this->staging->query($sql);
                    if(!$query) {
                        throw new Exception('Unable to delete call '.$this->call['info']['call_id'].' from the staging server.');
                    }
                }
                catch(PDOException $e) {
                   $this->informer("FATAL",$e->getMessage());
                }
            }

        }
        catch(Exception $e) {
            $this->informer("FATAL",$e->getMessage());
        }
    }
    catch(PDOException $e) {
        $this->informer("FATAL","We're unable to transport the call from the staging to production server. Error: ".$e->getMessage());
    }
}
  • 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-06T04:03:35+00:00Added an answer on June 6, 2026 at 4:03 am

    I am assuming that it is an escaping problem.

    Try This:

    ...
    try {
        $sql = "DELETE FROM `calls` WHERE `id`= :id";
        $stmtx = $this->staging->prepare($sql);
        $stmtx->execute(array($this->call['info']['call_id']));
        if(!query) {
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have decided to create a new table in my database that will be
I have decided to move a project from PHP to Python and despite hours
I have decided to learn another language and am in the picking phase. Currently
I have decided to move my C# daemon application (using dotConnect as ADO.NET provider)
Finally I have decided to get rid of aptana from eclipse but the Software
I have decided to learn Silverlight, but apart from knowing how to write apps,
I have decided to use crypt() to encrpyt my passwords on my database using
I have decided to change a search from using LIKE '%' + @searchTerm +
We have a database and have decided to enable it for FileStream use. I
I have done enough research and have decided to move the JavaScript to the

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.