Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
I am working with Join This is the error which i recive
  • I have try to join oil_demos and oil_comments two table with id and FK_id 
    and wirte the code in oil/demo model
     protected static $_has_many = array('comments' => array(
                'model_to' => 'Model_Oil_Comment',
                'key_from' => 'id',
                'key_to' => 'id',
                'cascade_save' => true,
                'cascade_delete' => false,
            // there are some more options for specific relation types
        ));
    please help n this

  • Fuel\Core\Database_Exception [ Error ]:
    SQLSTATE[42S22]: Column not found: 1054 Unknown column 't1.created_at'
    in 'field list' with query: "SELECT `t0`.`id` AS `t0_c0`, `t0`.`title`
    AS `t0_c1`, `t0`.`mnumber` AS `t0_c2`, `t0`.`body` AS `t0_c3`,
    `t0`.`created_at` AS `t0_c4`, `t0`.`updated_at` AS `t0_c5`,
    `t1`.`comment_id` AS `t1_c0`, `t1`.`id` AS `t1_c1`, `t1`.`comment` AS
    `t1_c2`, `t1`.`created_at` AS `t1_c3`, `t1`.`updated_at` AS `t1_c4` FROM
    `oil_demos` AS `t0` LEFT JOIN `oil_comments` AS `t1` ON (`t0`.`id` =
    `t1`.`id`)"

    The error message is pretty obvious. You have specificied a column in your model properties (of in this case "oil_comments"), that does not exist in the table.
  • i have correct it but not iam geting the error about comment not found which is new the join table, 
    here is the cde of the oil_demo model 
    <?php

    class Model_Oil_Demo extends \Orm\Model {

        protected static $_properties = array(
            'id',
            'title',
            'mnumber',
            'body',
            'created_at',
            'updated_at',
        );
        
      
     
        protected static $_has_many = array('comments' => array(
                'model_to' => 'Model_Oil_Comment',
                'key_from' => 'id',
                'key_to' => 'id',
                'cascade_save' => true,
                'cascade_delete' => false,
           // there are some more options for specific relation types
        ));
        protected static $_observers = array(
            'Orm\Observer_CreatedAt' => array(
                'events' => array('before_insert'),
                'mysql_timestamp' => false,
            ),
            'Orm\Observer_UpdatedAt' => array(
                'events' => array('before_save'),
                'mysql_timestamp' => false,
            ),
        );

    }
  • HarroHarro
    Accepted Answer
    It says

    OutOfBoundsException [ Error ]: Property "comment" not found for Model_Oil_Demo.

    And where is this property? Not in your properties list, and it's not a relation either (that is called 'comments').

    Please try to debug it yourself before posting everything here, this was a simple issue.
  • Sorry for your inconvenience.. but am new to fuelphp and MVC concept and also i a trying to learn on my own and your are only one with whom i can share my problem and solve it.

    so please provide me with the help it will be very great-full of u.. 
  • No problem.

    Just trying to say that you learn more by trying to understand the error message and why you get it then by asking someone else. If you can't figure it out, we're always here to help.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion