2017 © Pedro Peláez
 

library sheetdb-php

PHP Library for accessing google spreadsheet content via SheetDB. https://sheetdb.io

image

sheetdb/sheetdb-php

PHP Library for accessing google spreadsheet content via SheetDB. https://sheetdb.io

  • Saturday, December 30, 2017
  • by sheetdb
  • Repository
  • 0 Watchers
  • 3 Stars
  • 52 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 24 % Grown

The README.md

PHP SheetDB Class

Installation

The SheetDB PHP Library is available through Composer, (*1)

composer require sheetdb/sheetdb-php

Test spreadsheet

At any time you can play with our test API here: https://sheetdb.io/api/v1/58f61be4dda40, (*2)

You can also go to Google Sheets and play with it: https://docs.google.com/spreadsheets/u/2/d/1mrsgBk4IAdSs8Ask5H1z3bWYDlPTKplDIU_FzyktrGk/edit The spreadsheet resets every hour., (*3)

Basic usage

In order to instantiate SheetDB connection you need to give an api id. You can find it in SheetDB Dashboard., (*4)

require('vendor/autoload.php');
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

Searching

You can use search method to find only specific rows. You have 2 options. Search rows that meets all of the conditions or search rows that meets at least one of the conditions., (*5)

You can use second parameter if you want the search to be case sensitive (it is boolean). By default it is not case sensitive., (*6)

$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

Creating a row(s)

If you want to create a new row you'll need to pass an array with key_name => value. If you want to create multiple rows that should be an array of arrays., (*7)

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

Updating a row(s)

First two parameters are key and value that need to match, third argument is array similar to the create one., (*8)

Fourth parameter is optional. If it's true not specified values will be emptied., (*9)

$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

Update the batch of rows in the spreadsheet

Update for various queries. First argument is data itself. Each object in it should have a query key with the actual query (for example, "id=5"), and the remaining keys will be updated, as in a regular PATCH / PUT request., (*10)

Second parameter is optional. If it's true not specified values will be emptied., (*11)

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

Delete a row(s)

Just like in update first two parameters are key and value. Every row that will match query will be deleted., (*12)

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

The Versions

30/12 2017

dev-master

9999999-dev

PHP Library for accessing google spreadsheet content via SheetDB. https://sheetdb.io

  Sources   Download

MIT

The Requires

  • php >=5.5

 

by Avatar sheetdb

30/12 2017

1.0.2

1.0.2.0

PHP Library for accessing google spreadsheet content via SheetDB. https://sheetdb.io

  Sources   Download

MIT

The Requires

  • php >=5.5

 

by Avatar sheetdb

28/11 2017

1.0.1

1.0.1.0

PHP Library for accessing google spreadsheet content via SheetDB. https://sheetdb.io

  Sources   Download

MIT

The Requires

  • php >=5.5

 

by Avatar sheetdb

06/10 2017

1.0.0

1.0.0.0

PHP Library for accessing google spreadsheet content via SheetDB. https://sheetdb.io

  Sources   Download

MIT

The Requires

  • php >=5.5

 

by Avatar sheetdb