PHP code example of phant / client

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

    

phant / client example snippets


use Phant\Client\Service\MySQL as ClientMySQL;

$clientMySQL = new ClientMySQL(
	'127.0.0.1',
	'my_db',
	'my-user',
	'my-pass',
	'3306',
	'utf8mb4'
);

$clientMySQL->execute(
	'
	INSERT INTO `my_table`
	SET	`col_1`	= :val_col_1
	,	`col_2`	= :val_col_2
	',
	[
		':val_col_1' => 'foo',
		':val_col_2' => 'bar',
	]
);

$list = $clientMySQL->getList(
	'
	SELECT *
	FROM `my_table`
	WHERE	`col_1`	= :val_col_1
	,		`col_2`	= :val_col_2
	',
	[
		':val_col_1' => 'foo',
		':val_col_2' => 'bar',
	]
);

$list = $clientMySQL->getListByColumnValue(
	'my_table',
	'col_1',
	'foo'
);

$item = $clientMySQL->get(
	'
	SELECT *
	FROM `my_table`
	WHERE	`col_1`	= :val_col_1
	,		`col_2`	= :val_col_2
	',
	[
		':val_col_1' => 'foo',
		':val_col_2' => 'bar',
	]
);

$item = $clientMySQL->getByColumnValue(
	'my_table',
	'col_1',
	'foo'
);

$exist = $clientMySQL->get(
	'
	SELECT *
	FROM `my_table`
	WHERE	`col_1`	= :val_col_1
	,		`col_2`	= :val_col_2
	',
	[
		':val_col_1' => 'foo',
		':val_col_2' => 'bar',
	]
);

$exist = $clientMySQL->existByColumnValue(
	'my_table',
	'col_1',
	'foo'
);

use Phant\Client\Service\S3 as ClientS3;

$clientS3 = new ClientS3(
	$region,
	$endpoint,
	$accessKey,
	$secretKey,
);
$clientS3->setObject($bucket, 'foo', 'bar');
$bar = $clientS3->getObject($bucket, 'foo');
$clientS3->deleteObject($bucket, 'foo');

use Phant\Client\Service\S3 as ClientS3;
use Phant\Client\Service\S3\Bucket as ClientS3Bucket;

$clientS3Bucket = new ClientS3Bucket(
	new ClientS3(
		$region,
		$endpoint,
		$accessKey,
		$secretKey,
	),
	$bucket
);
$clientS3Bucket->set('foo', 'bar');
$bar = $clientS3Bucket->get('foo');
$clientS3Bucket->delete('foo');