PHP SDK Getting Started

Test and QA codecov Packagist Version PHP

Install

$ composer require sqlitecloud/sqlitecloud

SQLite Cloud is a powerful PHP package that allows you to interact with the SQLite Cloud database seamlessly. It provides methods for various database operations. This package is designed to simplify database operations in PHP applications, making it easier than ever to work with SQLite Cloud.

Example

<?php

require_once 'vendor/autoload.php';

use SQLiteCloud\SQLiteCloudClient;
use SQLiteCloud\SQLiteCloudRowset;

// Open the connection to SQLite Cloud
$sqlite = new SQLiteCloudClient();
$sqlite->connectWithString('sqlitecloud://myhost.sqlite.cloud:8860?apikey=myapikey');

// You can autoselect the database during the connect call
// by adding the database name as path of the SQLite Cloud
// connection string, eg:
// $sqlite->connectWithString("sqlitecloud://myhost.sqlite.cloud:8860/mydatabase?apikey=myapikey");
$db_name = 'chinook.sqlite';
$sqlite->execute("USE DATABASE {$db_name}");

 /** @var SQLiteCloudRowset */
$rowset = $sqlite->execute('SELECT * FROM albums WHERE ArtistId = 2');

printf('%d rows' . PHP_EOL, $rowset->nrows);
printf('%s | %s | %s' . PHP_EOL, $rowset->name(0), $rowset->name(1), $rowset->name(2));
for ($i = 0; $i < $rowset->nrows; $i++) {
  printf('%s | %s | %s' . PHP_EOL, $rowset->value($i, 0), $rowset->value($i, 1), $rowset->value($i, 2));
}

$sqlite->disconnect();

PHP Admin

To better understand the PHP APIs usage we developed a simple PHP Admin interface that can be used to administer any SQLite Cloud node.

You can login using admin credentials: PHP Admin Login

And then administer your node with a convenient user interface: PHP Admin Overview

PHP Admin source code is available in a GitHub repo.

More