yapro/doctrine2-orientdb-restful-driver

Doctrine2 PHP RESTful 驱动程序,用于 OrientDB 图形数据库。

dev-master 2014-06-11 08:53 UTC

This package is not auto-updated.

Last update: 2024-09-24 02:16:42 UTC


README

系统要求

从 develop 分支安装 OrientDB v.1.7。最后检查的版本为

commit 4f3aba5faa6a404367aea41e3fbab3dbe7c06da4
Author: enisher <enisher@gmail.com>
Date:   Thu May 15 23:33:51 2014 +0300

要与数据库一起工作,你必须执行以下操作。

启动数据库(完整路径)

$ /var/www/orientDB/bin/server.sh

如果你收到错误

java: command not found

安装 java,例如 java 1.7.0_45。你可以使用版本命令确认

$ java -version

设置

  1. 在文件 /app/config/config.yml 中替换字符串

    driver: %database_driver%

在这个字符串上

driver_class:   OrientDB\Driver
  1. 更改你在文件中的数据库连接设置

    /app/config/parameters.yml

例如,默认设置

parameters:
    database_driver: pdo_mysql
    database_host: localhost
    database_port: 2480
    database_name: GratefulDeadConcerts
    database_user: admin
    database_password: admin
    mailer_transport: smtp
    mailer_host: 127.0.0.1
    mailer_user: null
    mailer_password: null
    locale: en
    secret: ThisTokenIsNotSoSecretChangeIt
  1. 将以下代码添加到你的 composer.json 中
      "require": {
          ...
          "yapro/doctrine2-orientdb-restful-driver": "dev-master"
      },

然后运行命令

$ composer update yapro/doctrine2-orientdb-restful-driver --prefer-source

完成。

如何使用它

  1. 创建你的实体类(PHP 文件),并为字段 rid 添加 PHPDoc 注释,例如
/**
 * @ORM\Id
 * @ORM\Column(type="bigint", name="@rid")
 * @ORM\GeneratedValue(strategy="IDENTITY")
 */
private $rid = 0;
  1. 运行控制台命令以创建/更新你的实体

    $ php app/console doctrine:schema:update --force

如果你删除实体类,此命令不会在 OrientDB 中删除类(表)。如果你需要此操作,请使用以下命令在 OrientDB 中删除类(表)

orientdb {YouDatabase}> drop class YouEntityName

单元测试

你可以使用以下命令检查你的修复(或功能)

$ bin/phpunit -c app vendor/yapro/doctrine2-orientdb-restful-driver/Tests/Crud.php --env=dev

帮助

你的实体模式,Doctrine 在 \Doctrine\ORM\Tools\SchemaTool::getUpdateSchemaSql 中获取和比较

$fromSchema - schemas from you database

$toSchema - schemas from you classes

如果想要练习查询,请连接控制台客户端到数据库

$ /var/www/orientDB/bin/console.sh

orientdb> connect remote:localhost root You_password ( from file config/orientdb-server-config.xml )

如果你在控制台客户端中创建类(表),并使用 RESTful 驱动程序,你可能需要看到在 OrientDB 控制台中的此更新。为此操作,请运行

orientdb {YouDatabase}> reload schema

然后

orientdb {YouDatabase}> info