Question

My schema has a column that is of type "bit(1)". I haven't found a way that this can be expressed in Fuel. They don't seem to support the "bit" type and can't properly build insert queries.

Is there a way (possibly undocumented) to get Fuel to support this?

Was it helpful?

Solution

hmm... the orm supposedly accepts the bit field.

i have created a model from database. Look my migration script and model, maybe it can help you.

Model

class Model_Test extends \Orm\Model
{
    protected static $_properties = array(
        'id',
        'whatever',
    );

    protected static $_table_name = 'tests';

}

Migration script

builded from an existing table using the command: oil refine fromdb:model test

namespace Fuel\Migrations;

class Create_tests
{
    public function up()
    {
        \DBUtil::create_table('tests', array(
            'id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true, 'unsigned' => true),
            'whatever' => array('type' => 'bit'),

        ), array('id'));
    }

    public function down()
    {
        \DBUtil::drop_table('tests');
    }
}

In the controller, you must be need cast the value as INT

$f  = Input::post('whatever_post_field');

$o  = Model_Test::forge(array('whatever' => (int)$f));
$o->save();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top