PHP code example of porebskk / simple-php-document-store
1. Go to this page and download the library: Download porebskk/simple-php-document-store 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/ */
porebskk / simple-php-document-store example snippets
//Setting up the DbalAdapter, we are using here Sqlite in memory mode
//ger::getConnection($connectionParams);
$conn->exec('PRAGMA foreign_keys = ON');
$dbalAdapter = new DbalAdapter($conn);
//this is only
$query = new Query();
//Finding document where the JSON Path "person.head.eyes" is either red or orange
//Allowed operators depend on the adapter implementation
//for DBAL see the ExpressionBuilder::* constants
$query->whereAnd(
(new OrStatement())->add(
new WhereStatement('person.head.eyes', '=', 'red'),
new WhereStatement('person.head.eyes', '=', 'orange')
)
);
$documents = $dbalAdapter->searchByQuery($query);
//It is possible to wrap AND/OR Statement as deep as possible
$query->whereAnd(
(new OrStatement())->add(
new WhereStatement('person.head.eyes', '=', 'blue'),
(new AndStatement())->add(
new WhereStatement('person.head.eyes', '=', 'orange'),
new WhereStatement('person.character.crazy', '=', 'yes')
)
),
new WhereStatement('person.feet', '=', 'big')
);