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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:17:42+00:00 2026-06-03T03:17:42+00:00

I came across what looks like an odd issue with either Zend_Db or PHP’s

  • 0

I came across what looks like an odd issue with either Zend_Db or PHP’s PDO MySQL driver, that perhaps stems from my lack of knowledge of those two.

Let’s assume I have a MySQL Table with a NULLable TIME field. If I run a query like this in MySQL client:

UPDATE mytable SET mytime = NULL WHERE id = 1;

Everything works as expected and mytime field will hold NULL as value after this query.

However, if I run the exact same query in PHP through the Zend_Db_Adapter, the mytime field is set to '0:0:0' after such query:

$db->getConnection()->exec('UPDATE mytable SET mytime = NULL WHERE id = 1');

How do I set that TIME field to NULL?

I’m using PHP5.3 with PDO MySQL driver, Zend Framework 1.11 and MySQL 5.1.

  • 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-03T03:17:43+00:00Added an answer on June 3, 2026 at 3:17 am

    What you have should work, i.e.:

    $db->getConnection()->exec('UPDATE mytable SET mytime = NULL WHERE id = 1');
    

    That should work. I tested it.

    Caveat

    If the data type time is NOT NULL, then trying to set it to NULL will cause the value NULL to be defaulted to 00:00:00, which may be unexpected behaviour e.g.:

    CREATE TABLE `test` (
        `time` datetime NOT NULL
    );
    

    Trying to insert or update the time field above with NULL will cause the value 00:00:00 to be inserted.

    This is similar for date, datetime, and a few other data types. e.g. Trying to set a data type datetime which is NOT NULL to NULL will default its value to 0000-00-00 00:00:00.

    NOTE: Mysql will not throw an error when you try to set a NULL value to a NUT NULL data type, you can change this behaviour by setting MySQL’s SQL_MODE to STRICT_ALL_TABLES: see this stackoverflow question.

    The Fix

    Change the field to allow NULL and it should be fine:

    CREATE TABLE `test` (
        `time` datetime DEFAULT NULL
    );
    

    Now the time field can be set to NULL.

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

Sidebar

Related Questions

I came across a mysql query that looks like this: SELECT SUM(some_amount*(some_field!=90)*(some_date < '2011-04-22'))
I came across some code today that looks like this: subroutine sub(hello,world,this,routine,takes,a, & &
I just started with cocos2D and came across something that looks like this ..
I just came across code that looks like this: if (foo == bar){}else{ }
I came across some code written in C that looks like this: if (file
I came across a piece of code which looks like this: jQuery(function($) { $('#saySomething').click(function()
Came across this code: <?php require_once 'HTTP/Session/Container/DB.php'; $s = new HTTP_Session_Container_DB('mysql://user:password@localhost/db'); ini_get('session.auto_start') or session_start();
I'm working on a Dashboard widget and I came across a code that looks
Okay so I came across a code which looks like @documents_names = sort {
I came across what looks like strange behavior from the clang++ compiler for 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.