Saving nulls to database instead of empty strings

You are viewing revision #1 of this wiki article.
This version may not be up to date with the latest version.
You may want to view the differences to the latest version.

next (#2) »

To write null instead of empty strings to database when saving empty values you need to set up your DB connection as follows:

  'connectionString' => 'mysql:host=localhost;dbname=test',
  'username' => 'root',
  'password' => '',
  'charset' => 'utf8',
  // here it is:
  'nullConversion' => PDO::NULL_EMPTY_STRING,
13 0
Viewed: 14 839 times
Version: Unknown (update)
Category: Tips
Tags: database, null
Written by: samdark
Last updated by: samdark
Created on: May 7, 2011
Last updated: 8 years ago
Update Article


View all history

Related Articles