Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2012
    Posts
    412
    Plugin Contributions
    0

    Default zen_db_perform and null values

    Function zen_db_perform apparently does not treat null values properly, at least with PHP 8. If inserting or updating a table containing a field with a null value, the function changes the value from null to '' when written to the table. Although the function has a case for NULL and null which would write null, casting a null value to a string will convert the value to '', so the case statements won't process it. This causes problems trying to write a datetime field, resulting in a fatal error. Looks like the same code in zc1.5.8.

    Guess I need to use $db->Execute("INSERT....")???

    Dave
    zc157c, php 8.0.28

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,576
    Plugin Contributions
    88

    Default Re: zen_db_perform and null values

    Whenever I've used zen_db_perform to insert/update 'NULL' values, I've supplied the (string)'NULL' as the associated value.

  3. #3
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,756
    Plugin Contributions
    124

    Default Re: zen_db_perform and null values

    You can also just not touch the field unless the value is non-null.

    See (for example) banner_manager.php line 156 and how date_added is updated on adds.
    That Software Guy. My Store: Zen Cart Support
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

 

 

Similar Threads

  1. Replies: 7
    Last Post: 4 May 2016, 01:59 AM
  2. v151 How to insert a NULL value when using zen_db_perform() ?
    By retched in forum Contribution-Writing Guidelines
    Replies: 2
    Last Post: 17 Nov 2012, 02:04 AM
  3. Replies: 11
    Last Post: 15 Jan 2010, 04:44 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR