edizduman/neo4j-php-ogm

Neo4j 的 PHP 对象图映射器

1.0.4.RC1 2017-03-23 13:24 UTC

README

PHP 中 Neo4j 的对象图映射器

Build Status Latest Stable Version Latest Unstable Version Total Downloads License

当前版本 : 1.0.0-RC1

基本用法

通过声明具有映射注解的实体来存储/检索实体。它与 Doctrine2 ORM 非常相似。

<?php

namespace Demo;

use GraphAware\Neo4j\OGM\Annotations as OGM;

/**
 * @OGM\Node(label="User")
 */
class User
{
    /**
     * @OGM\GraphId()
     */
    protected $id;

    /**
     * @OGM\Property(type="string")
     */
    protected $name;

    /**
     * @OGM\Property(type="int")
     */
    protected $age;


    // Getters and Setters
}
$this->em = $this->getEntityManager();
// The entity manager is generally created somewhere else in your application and available in the dependency injection container.
// More info about the creation is in the documentation

// Creating and Persisting a User

$bart = new User('Bart Johnson', 33);
$this->em->persist($bart);
$this->em->flush();

// Retrieving from the database

$john = $this->em->getRepository(User::class)->findOneBy(['name' => 'John Doe']);
echo $john->getAge();

// Updating
$john->setAge(35);
$this->em->flush();

文档

文档可在这里找到。

寻求帮助

如有问题,请在 StackOverflow 上创建一个新的线程,并使用 graphawareneo4jneo4j-php-ogm 标签。

如有问题,请在存储库中提出 GitHub 问题。

许可证

本库在 MIT 许可证下发布,请参阅此包附带的其他许可证文件。