使用中ガスORM for CodeIgniter。テーブルのhttp://gasorm-doc.taufanaditya.com/configuration.htmlガスORM - 自動作成表エラーメッセージ
ガスORMサポートの自動作成:に言ったよう
。つまり、既存のガスモデルをデータベースに変換することができます。セキュリティ上の理由から、このオプションはデフォルトで無効になっています。
$config['auto_create_tables'] = TRUE;
をし、私はmigration.phpに移行を可能にして、モデルのフォルダと呼ばuser.phpとblog.phpで2クラスを作成:有効にします。
Userクラス:
<?php
namespace Model;
use \Gas\Core;
use \Gas\ORM;
class User extends ORM {
public $primary_key = 'id';
function _init()
{
self::$relationships = array (
'blog' => ORM::has_many('\\Model\\Blog');
);
self::$fields = array(
'id' => ORM::field('auto[10]'),
'username' => ORM::field('char[64]'),
'password' => ORM::field('char[255]'),
'email' => ORM::field('char[255]'),
);
}
}
Blogclass:
<?php namespace Model;
use \Gas\Core;
use \Gas\ORM;
class Blog extends ORM {
public $primary_key = 'id';
function _init()
{
self::$relationships = array (
'user' => ORM::belongs_to('\\Model\\User')
);
self::$fields = array(
'id' => ORM::field('auto[10]'),
'title' => ORM::field('char[255]', array('required','max_length[255]')),
'body' => ORM::field('string'),
'modified_at' => ORM::field('datetime'),
'created_at' => ORM::field('datetime'),
);
$this->ts_fields = array('modified_at','[created_at]');
}
}
私はページを更新し、PAのようなコードを見てエラーを表示する:
A PHP Error was encountered
Severity: Runtime Notice
Message: Only variables should be passed by reference
Filename: classes/core.php
Line Number: 2460
Backtrace:
File: /application/third_party/gas/classes/core.php
Line: 2460
Function: _error_handler
File: /application/third_party/gas/classes/core.php
Line: 320
Function: _generate_tables
File: /application/third_party/gas/classes/core.php
Line: 360
Function: __construct
File: /application/third_party/gas/bootstrap.php
Line: 229
Function: make
File: /application/libraries/Gas.php
Line: 111
Function: include_once
File: /application/controllers/Home_Controller.php
Line: 7
Function: __construct
File: /index.php
Line: 315
Function: require_once
本当にこのエラーが発生しました。誰も私の問題を解決するために私を助けることができますか?
7行目のHome_Controller.phpには何がありますか? – Tpojka
@Tpojka:これはコントローラファイルで、ビューを処理または呼び出す(この場合はhomeviewというPHPファイル)。このような呼び出しのためのコードの使用$ this-> load-> view( 'homeview'); 。 homeviewは今のところHTMLコードしか入っていないphpファイルです。 – Michael
そのファイルの7行目で最初にエラーが検出されたというエラーメッセージが表示されますか?問題のファイルコードも投稿してください。 – Tpojka