- 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:connection:concat

# concat

    string concat(
           string $inputString
           )

## Description

The function `concat()` takes an variable list of strings, and returns a database-specific string of concatenated values. It is important to recognize the difference between concatenating a database field or a string whn using the method in an SQL statement

## Usage

    /*
     * Assume MySQL database
     */
    $string = $db->concat('VOGON','POETRY','READING');

    /*
     * Returns: CONCAT(VOGON,POETRY,READING);
    */

## Concatenating Strings And Database Fields

In order to concatenate database fields and strings together it is necessary to quote the strings

    /*
    * Best methodology
    */
    $s = $db->quote(', Arthur Dent');

    $SQL = "UPDATE hitchhikers
               SET last_name = {$db->concat(last_name,$s)}
             WHERE first_name='Arthur'
               AND last_name='Dent'";

    $db->execute($SQL);

    $SQL = "SELECT last_name FROM hitchhikers
             WHERE first_name='Arthur'";

    print $db->getOne($SQL);

    /*
    * Prints "Dent, Arthur Dent"
    */

v5/reference/connection/concat.txt · Last modified: 2016/01/17 17:13 by mnewnham

### Page Tools

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