Getting nulls from database instead of empty strings

13 0
11
Viewed: 24 057 times
Version: 1.1
Category: Tips
Written by: samdark samdark
Updated by: samdark samdark
Created: May 7, 2011
Updated: 15 years ago

To get null from database instead of empty strings you need to set up your DB connection as follows:

'db'=>array(
  'connectionString' => 'mysql:host=localhost;dbname=test',
  'username' => 'root',
  'password' => '',
  'charset' => 'utf8',
   
  // here it is:
  'nullConversion' => PDO::NULL_EMPTY_STRING,
),