| title | PHP SDK Methods |
|---|---|
| description | Methods available in the SQLite Cloud PHP SDK. |
| customClass | sdk-doc badge-doc php-doc |
| category | sdks |
| status | publish |
SQLiteCloudClient.connect($hostname, $port = 8860)
SQLiteCloudClient.connectWithString('sqlitecloud://myhost.sqlite.cloud:8860?apikey=myapikey')To connect to SQLite Cloud, you need to first allocate an SQLiteCloud Client instance and then inizialize some mandatory public properties: connection string or username and password. The SQLiteCloud PHP class has the following properties:
class SQLiteCloudClient {
public $username = '';
public $password = '';
public $database = '';
public $timeout = NULL;
public $connect_timeout = 20;
public $compression = false;
// ...and more
}use SQLiteCloud\SQLiteCloudClient;
$sqlitecloud = new SQLiteCloudClient();
try {
if ($sqlitecloud->connectWithString('sqlitecloud://myhost.sqlite.cloud:8860/mydatabase?apikey=myapikey') == false) {
$msg = $sqlitecloud->errmsg;
return $msg;
}
} catch (Exception $e) {
return $e->getMessage();
}
return true;use SQLiteCloud\SQLiteCloudClient;
$sqlitecloud = new SQLiteCloudClient();
$sqlitecloud->username = 'admin';
$sqlitecloud->password = 'pass';
try {
if ($sqlitecloud->connect('mynode.sqlite.cloud', 8860) == false) {
$msg = $sqlitecloud->errmsg;
return $msg;
}
} catch (Exception $e) {
return $e->getMessage();
}
return true;SQLiteCloudClient.execute($command)Submits a command to the server and waits for the result. The command can be any SQLite statement or any built-in SQLite Cloud command.
falseis returned in case of an errortrueis returned in case of OK replyNULLis returned in case of NULL reply- An
integeror adoublein case of numeric reply - A
stringif the reply is a string value - A PHP
arrayif the reply contains multiple values - An
SQLiteCloudRowsetinstance in case of a query reply
use SQLiteCloud\SQLiteCloudClient;
$sqlitecloud = new SQLiteCloudClient();
$sqlitecloud->connectWithString('sqlitecloud://myhost.sqlite.cloud:8860/mydatabase?apikey=myapikey')
$result = $sqlitecloud->execute('LIST INFO');
$sqlitecloud->disconnect();SQLiteCloudRowset.dump()Print the Rowset on standard output.
use SQLiteCloud\SQLiteCloudClient;
$sqlitecloud = new SQLiteCloudCient();
$sqlitecloud->connectWithString('sqlitecloud://myhost.sqlite.cloud:8860/mydatabase?apikey=myapikey')
$result = $sqlitecloud->execute('LIST INFO');
$result->dump();
$sqlitecloud->disconnect();SQLiteCloudRowset.name($col)Use the function to retrieve the name of a column in the Rowset at index $col (from 0 to SQLiteCloudRowset.ncols).
A string with the column name.
use SQLiteCloud\SQLiteCloudClient;
use SQLiteCloud\SQLiteCloudRowset;
$sqlitecloud = new SQLiteCloudClient();
$sqlitecloud->connectWithString('sqlitecloud://myhost.sqlite.cloud:8860/mydatabase?apikey=myapikey')
/** @var SQLiteCloudRowset */
$result = $sqlitecloud->execute('LIST INFO');
$col1name = $result->name(0);
$sqlitecloud->disconnect();SQLiteCloudRowset.value($row, $col)Use the function to retrieve the value of an item in the Rowset at row $row (from 0 to SQLiteCloudRowset.nrows) and column $col (from 0 to SQLiteCloudRowset.ncols).
The column value.
use SQLiteCloud\SQLiteCloudClient;
use SQLiteCloud\SQLiteCloudRowset;
$sqlitecloud = new SQLiteCloudClient();
$sqlitecloud->connectWithString('sqlitecloud://myhost.sqlite.cloud:8860/mydatabase?apikey=myapikey')
/** @var SQLiteCloudRowset */
$result = $sqlitecloud->execute('LIST INFO');
$col = 1;
$row = 1;
$value = $result->value($row, $col);
$sqlitecloud->disconnect();SQLiteCloudClient.disconnect()The disconnect public method closes the connection with the server.
use SQLiteCloud\SQLiteCloudClient;
$sqlitecloud = new SQLiteCloudClient();
$sqlitecloud->connectWithString('sqlitecloud://myhost.sqlite.cloud:8860/mydatabase?apikey=myapikey')
$sqlitecloud->disconnect();