Getting nulls from database instead of empty strings

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,
),
13 0
11 followers
Viewed: 20 651 times
Version: 1.1
Category: Tips
Tags: database, null
Written by: samdark
Last updated by: samdark
Created on: May 7, 2011
Last updated: 13 years ago
Update Article

Revisions

View all history

Related Articles