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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:27:52+00:00 2026-05-28T14:27:52+00:00

I try to execute insert statement with on duplicate part. As I know Zend

  • 0

I try to execute insert statement with “on duplicate” part. As I know Zend doesn`t support this, so I use simple statement:

$sql = "INSERT INTO agent(`inn`, `name`, `created`) VALUES(:inn, :name, :created) ON      
DUPLICATE KEY UPDATE `inn` = :inn, `name` = :name, `created` = :created";
$stmt = $this->db->prepare($sql);
$stmt->execute($bind);

Where $bind – is array:

array(
  'inn'=>1234567890,
  'name'=>'test user', 
  'created' = new Zend_Db_Expr('NOW()')
);

If I try this query through phpMyAdmin – all works fine,
but after script execution the “created” column value is ‘0000-00-00 00:00:00’.

WTF?

  • 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-28T14:27:53+00:00Added an answer on May 28, 2026 at 2:27 pm

    You can’t use an expression as an argument to a placeholder in a prepared statement. It will be interpreted as a string. This has nothing to do with zend framework.

    You can either created a formatted date string in php and use that, or use now() in the prepared statement like

     VALUES(:inn, :name, NOW())
    

    Another solution, if you need to sometimes supply a datetime, and sometimes use NOW(), is using conditionals to check for that specific case

     VALUES(:inn, :name, IF(:created = 'NOW()', NOW(), :created))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to execute this statement in Oracle SQL Developer 2.1 a dialog
im getting this error: cursor.execute('INSERT INTO COURSE (title) VALUES (?)',(title)) sqlite3.ProgrammingError: Incorrect number of
I am writing a simple between statement. create table temp(mid int) insert into temp
I have an INSERT INTO ... ON DUPLICATE KEY UPDATE ... statement that executes
In a sort of try/catch form I want to execute a bash that doesn't
As we Android developers know, the SQLiteDatabase execSQL method can execute only one statement.
How can you fix the SQL-statement in Python? The db connection works. However, cur.execute
I'm try to insert values into my sqlite table using a python script. It
I am getting this error when running a save insert/update command: SEVERE: null java.sql.SQLIntegrityConstraintViolationException:
I'm trying to execute a basic INSERT statement on a MySQL table from a

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.