- skip to content

# Database Abstraction Layer

### User Tools

- Login

### Site Tools

- Recent changes
- Media Manager
- Sitemap

### Sidebar

##### Resources

- Reference Manual
- User Guide
- The Data Dictionary
- ADOdb-xmlschema
- ADOdb Active Record
- Performance Monitoring
- Date/Time Library
- Session Management Library
- Unsupported Addons
- Coding Standards

##### Supported Databases

- Access
- ADO
- CSV
- Firebird
- Frontbase
- IBM DB2
- Informix
- Interbase
- LDAP
- Microsoft SQL Server
- MySQL
- Netezza
- ODBC
- ODBTP
- Oracle
- PDO
- Postgresql
- SAP ADS
- SAP ASE
- SAP Maxdb
- SAP Sqlanywhere
- Sqlite
- Sybase
- Plain Text
- Visual Foxpro

##### Other

- Feature Comparison Matrix
- Connection Matrix
- Include File Guide

v5:reference:adodb_force_type

# $ADODB_FORCE_TYPE

The behaviour of autoexecute, getupdatesql and getinsertsql when converting empty or null PHP variables to SQL is controlled by the global $ADODB_FORCE_TYPE variable.

Default is ADODB_FORCE_VALUE

# Constants

Constant | Value | Description
--- | --- | ---
ADODB_FORCE_IGNORE | 0 | All empty fields in array are ignored
ADODB_FORCE_NULL | 1 | All empty php null and string 'null' fields are changed to sql NULL values. Earlier release of ADOdb used ADODB_FORCE_NULLS
ADODB_FORCE_EMPTY | 2 | All empty php null and string 'null' fields are changed to sql empty or 0 values
ADODB_FORCE_VALUE | 3 | Value is left as it is. PHP null and string 'null' are set to sql NULL values. Empty fields are set to empty SQL values. This is the default value
New in version 6.0.0
ADODB_FORCE_NULL_AND_ZERO | 4 | If the field is of a string type, PHP character null and string 'null' are set to SQL NULL values. If the field is of an integer,logical or float type and is empty, it will be set to zero

### Usage

    $ADODB_FORCE_TYPE = ADODB_FORCE_EMPTY;

## Guidance

### Using ADODB_FORCE_IGNORE

Using this value while generating SQL statements creates more compact, efficient statements, it is impossible to deliberately set an existing value to NULL, as ADOdb will simply ignore the field whilst creating the update statement. To set a field empty, it must be set to the string value 'null'.

### The difference between EMPTY and NULL

When developing an application it is important to define a standard for fields with no value in them. the difference between the 2 is easily demonstrated in the following code snippet:

    $SQL = "SELECT * FROM some_table WHERE character_field = ''";

or:

    $SQL = "SELECT * FROM some_table WHERE character_field IS NULL";

v5/reference/adodb_force_type.txt · Last modified: 2016/01/18 20:39 by 66.249.75.225

### Page Tools

- Show pagesource
- Old revisions
- Backlinks
- Rename Page
- Back to top