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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:49:37+00:00 2026-06-09T23:49:37+00:00

My question is the exact same as How to Set a Value to NULL

  • 0

My question is the exact same as How to Set a Value to NULL when using Zend_Db

However, the solution given in that question is not working for me. My code looks like the following. I call updateOper on the Model class when update is clicked on the front end. Inside updateOper, I call another function trimData() where I first trim all whitespace and then I also check that if some of the fields are coming in empty or '' I want to set them to default values or NULL values. Therefore I am using new Zend_db_expr('null') and new Zend_db_expr('default') .

The code is as follows:

private function trimData(&$data ) {

    //Trim whitespace characters from incoming data.
    foreach($data as $key => $val)
    { 
        $data[$key] = trim($val);
        if($data['notes'] == '') {
            error_log("set notes to null/default value");
            $data['notes'] = new Zend_db_expr('DEFAULT');
        }
    }

}

public function updateOper($data, $id)
{
    $result = 0;

    $tData = $this->trimData($data);

    error_log("going to add data as ".print_r($data, true));
    $where = $this->getAdapter()->quoteInto('id = ?', $id);
    $result = $this->update($data, $where);

    return $result;
}

The error_log statement prints the $data array as follows:

[id] => 10    
[name] => alpha
[notes] => DEFAULT

As a result, the notes column has value =’DEFAULT’ instead of picking the default value given in the table definition.

I have been trying to figure out what is wrong, but have not been able to find a solution.
I would really appreciate your help.

Thanks so much!

  • 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-09T23:49:39+00:00Added an answer on June 9, 2026 at 11:49 pm

    Your $data[‘notes’] is being changed to the __toString() value of the Zend_Db_Expr instead of preserving the actual object.

    Maybe the reference is clogging things up. Else you may need to move the expression declaration into the actual update query.

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

Sidebar

Related Questions

Basically my question is the exact same one as this: Simple client/server, TCP/IP encrypting
Someone has asked the exact same question in April, without any answer. But since
I have almost the exact same question as at the following post (and I
This is driving me nuts. I believe I asked this exact same question, but
This is very similar to a previous question (and may be the exact same
This question is related but not the same as this: How do you give
I see that the question's been asked several times of how to set the
I wrote some code that looks like this: def get(x, y) @cachedResults.set(x,y, Math.hypot(x, y))
My question looks like a classic one, but I cannot find the exact same
So this question has the exact same symptoms of my problem. Security settings for

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.