0

In use Gas ORM for CodeIgniter.

Like what said in : http://gasorm-doc.taufanaditya.com/configuration.html

Gas ORM support auto-creation of tables. This mean you can convert your existing Gas models into a database. For security reasons, this option is disabled by default. To enable :

$config['auto_create_tables'] = TRUE;

And then i enable migration in migration.php and then create 2 class in models folder called user.php and blog.php. The code look like :

User class :

<?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]');
    }

}

When i refresh the pages, the page showing error:

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

I really stuck with this error. Can anyone help me to solve my problem?

Mr. Mike
  • 453
  • 5
  • 23
  • What is in Home_Controller.php at line 7? – Tpojka Oct 07 '16 at 10:48
  • @Tpojka : it is a controller file, to handle or call a view (in this case a php file called homeview). The code use for calling like this $this->load->view('homeview'); . homeview is php file which only contain HTML code for now. – Mr. Mike Oct 07 '16 at 11:00
  • Can you see in error message that is first error found because of line 7 of that file? Post file code in question too, please. – Tpojka Oct 07 '16 at 11:44

1 Answers1

0

I already trace my code, and the problem similar like this reference : Only variables should be passed by reference

The fact of this problem is maybe the code show error when running but actually the code completely its function. So i decide to turn the $config['auto_create_tables'] = TRUE; to $config['auto_create_tables'] = FALSE; after using this feature.

Community
  • 1
  • 1
Mr. Mike
  • 453
  • 5
  • 23