everdreamsoft / sandra
Sandra Ontologic Datagraph
Installs: 1 481
Dependents: 3
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 2
Open Issues: 2
Type:project
Requires
- ext-json: *
Requires (Dev)
- phpunit/phpunit: 8.*
This package is auto-updated.
Last update: 2024-12-10 19:18:30 UTC
README
Getting Started
Using composer
composer require evedreamsoft/sandra
To instantiate your datagraph
$sandra = new \SandraCore\System('myFirstDatagraph,
true, 'your_DB_HOST',
'your_DB_name',
'your_DB_username',
'your_db_password');
For example
$sandra = new \SandraCore\System('myFirstDatagraph,'true,'127.0.0.1','sandra','root','');
Writing data
Initialization
$sandra = new System('AnimalShelter',true);
$catFactory = new EntityFactory('cat','catFile',$sandra);
We create 3 cats
$felixEntity = $catFactory->createNew(['name' => 'Felix',
'birthYear' => 2012]);
$smokeyEntity = $catFactory->createNew(['name' => 'Smokey',
'birthYear' => 2015]);
$missyEntity = $catFactory->createNew(['name' => 'Missy',
'birthYear' => 2015,
'handicap' => 'blind'
]);
Each cat has name reference and birthYear the last cat Missy has additional "handicap" reference The resulting simplified datagraph will look like this
Reading data
$catFactoryForRead = new EntityFactory('cat','AnimalFile',$sandra);
//The factory is empty we need to load the 3 cats into memory
$catFactoryForRead->populateLocal(1000); //we read a limit of 1000 cats
$catEntityArray = $catFactoryForRead->getEntities();
foreach ($catEntityArray as $cat){
echo $cat->get('name')."\n";
}
returns :
Felix
Smokey
Missy