Sandra 本体数据图

安装量: 1,439

依赖者: 3

建议者: 0

安全: 0

星标: 3

关注者: 3

分支: 2

公开问题: 2

类型:项目

dev-master 2023-05-10 15:57 UTC

README

入门

使用 composer

composer require evedreamsoft/sandra

实例化你的数据图

$sandra = new \SandraCore\System('myFirstDatagraph,
true,    'your_DB_HOST',
'your_DB_name',
'your_DB_username',
'your_db_password');

例如

$sandra = new \SandraCore\System('myFirstDatagraph,'true,'127.0.0.1','sandra','root','');

写入数据

初始化

$sandra = new System('AnimalShelter',true);
$catFactory = new EntityFactory('cat','catFile',$sandra);

我们创建 3 只猫

$felixEntity = $catFactory->createNew(['name' => 'Felix',
    'birthYear' => 2012]);

$smokeyEntity = $catFactory->createNew(['name' => 'Smokey',
    'birthYear' => 2015]);


$missyEntity = $catFactory->createNew(['name' => 'Missy',
    'birthYear' => 2015,
    'handicap' => 'blind'
    ]);

每只猫都有一个名字引用和一个出生年份。最后一只猫 Missy 有一个额外的 "handicap" 引用。生成的简化数据图将看起来像这样

读取数据

 $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";
    
 }

返回

Felix

Smokey

Missy