sgpatil/orientdb

Laravel Orientdb 驱动器

v0.0.2 2015-04-15 12:41 UTC

This package is not auto-updated.

Last update: 2024-09-14 16:18:52 UTC


README

Orientdb 图 Eloquent 驱动器,适用于 Laravel 4

寻找Orientdb 驱动器,适用于 Laravel 5

快速参考

安装

将包添加到您的 composer.json 并运行 composer update

{
    "require": {
        "sgpatil/orientdb": "@dev"
    }
}

app/config/app.php 中添加服务提供者

'Sgpatil\Orientdb\OrientdbServiceProvider',

这将注册此包所需的全部类。

数据库配置

打开 app/config/database.php,将 orientdb 设置为默认连接

'default' => 'orientdb',

添加连接默认值

'connections' => [
    'orientdb' => [
        'driver' => 'orientdb',
        'host'   => 'localhost',
        'port'   => '2480',
        'database' => 'database_name',
        'username' => 'root',
        'password' => 'root'
    ]
]

在 'username' 和 'password' 字段中添加您的数据库用户名和密码。在 'database_name' 中添加您想要连接和使用的 Orientdb 数据库名称。

迁移

要创建迁移,您可以在 Artisan CLI 上使用 orient 命令

php artisan orient:make create_users_table

迁移将放置在您的 database/migrations 文件夹中,并将包含一个时间戳,这允许框架确定迁移的顺序。

您还可以使用 --table 和 --create 选项来指定表名,并指示迁移是否会创建新表

php artisan orient:make add_votes_to_users_table --table=users_votes

php artisan orient:make create_users_table --create=users

运行迁移

php artisan orient

如何使用

class User extends Orientdb {

    protected $fillable = ['name', 'email'];
}

$user = User::create(['name' => 'Some Name', 'email' => 'some@email.com']);

您可以通过将 Orientdb 扩展到模型类中来使用此功能。