- 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:getone

# getOne

##### Syntax

      mixed getOne(
         string $sql
         )

Executes the SQL and returns the first column of the first row. The recordset and remaining rows are discarded for you automatically. If an error occurs, either false or null is returned depending on the value of adodb_getone_eof.

You can use errorMsg() to get any the error details.

## Controlling the response if no records are found

By default, getOne returns NULL if no records are found. The global variable `$ADODB_GETONE_EOF` can be set to any value to indicate no match

## Usage

    $ADODB_GETONE_EOF = "-1";

    $SQL = "SELECT MAX(tickets) FROM arena WHERE zip_code = '80111'";
    $maxTickets = $db->GetOne($SQL);

    if ($maxTickets == -1)
        print "There are no arenas in zip code 80111";
    elseif ($maxTickets == 0)
        print "No tickets have been sold in zip code 80111";
    else
        print "The maximum number of tickets sold by arenas
               in Zip Code 80111 is $maxTickets";

v5/reference/connection/getone.txt · Last modified: 2016/01/16 14:51 by mnewnham

### Page Tools

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