PHP code example of lee-to / php-airtable

1. Go to this page and download the library: Download lee-to/php-airtable library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lee-to / php-airtable example snippets


use Airtable;


$client = new AirTable($token, $base, $http_client);
 php
$client->table('table_name')->list();
 php
$client->table('table_name')->retrieve('ID');
 php
$client->table('table_name')->sort("column", "direction")->list();
 php
$client->table('table_name')->fields(["Column1", "Column2"])->list();
 php
$client->table('table_name')->maxRecords(15)->list();
 php
$client->table('table_name')->pageSize(15)->list();
 php
$client->table('table_name')->offset('ID')->list();
 php
$client->table('table_name')->update('ID', ["Column1" => "Value"]);
 php
foreach($client->table('table_name')->list() as $record) {
    $record->update(["Column1" => "Value"]);
}
 php
$client->table('table_name')->create(["Column1" => "Value"]);
 php
$client->table('table_name')->delete('ID');
 php
foreach($client->table('table_name')->list() as $record) {
    $deleted = $record->delete();
    
    $deleted->isDeleted(); // Check is deleted or not
}
 php
foreach($client->table('table_name')->list() as $record) {
    $record->getId(); // ID 
    
    $record->COLUMN1; // Any fields in table 
}