PHP code example of sheetdb / sheetdb-php

1. Go to this page and download the library: Download sheetdb/sheetdb-php 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/ */

    

sheetdb / sheetdb-php example snippets



use SheetDB\SheetDB;

$sheetdb = new SheetDB('58f61be4dda40');
$response = $sheetdb->get(); // returns all spreadsheets data
$response = $sheetdb->keys(); // returns all spreadsheets key names
$response = $sheetdb->name(); // returns name of a spreadsheet document

$response = $sheetdb->search(['name'=>'Steve','age'=>'22']); // returns when name="Steve" AND age=22
$response = $sheetdb->searchOr(['name'=>'Steve','age'=>'19']); // returns when name="Steve" OR age=19

$response = $sheetdb->search(['name'=>'Steve'], true); // returns when name="Steve", this query is case sensitive

$sheetdb->create(['name'=>'Mark','age'=>'35']);
$sheetdb->create([
	['name'=>'Chris','age'=>'34'],
	['name'=>'Amanda','age'=>'29'],
]);

$sheetdb->update('name','Chris',['age'=>'33']); // it will change only age
$sheetdb->update('name','Chris',['age'=>'33'],true); // it will update age to 33 but all other values will be emptied, in this case a name

$sheetdb->batchUpdate([
    [
        'query' => 'id=1',
        'age' => '33',
    ],
    [
        'query' => 'id=2',
        'age' => '52',
    ]
]);

$sheetdb->delete('name','Chris'); // will delete all rows with name = "Chris"

composer