Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
ORM - Deleting Related Models with Conditions
  • Using the latest 1.5.3

    I found an issue when deleting a database entry where my related model has conditions using the related model's name, and does not get aliased correctly when attempting to find and delete the children.

    For example, blogs have many posts:

    'post'    => array(
          'key_from'        => 'id',
          'key_to'          => 'blog_id',
          'conditions'      => array(
            'order_by'      => array('post.display_order'),
          )
        ),

    I end up with an "unknown column" error, where the SQL does not replace the alias name in the condition part (order_by), so in the above example it would look like "unknown column 'post.display_order' in order clause".

    Note: In my working version, 'post' has a different table name defined in the protected static $_table_name variable.

    My models are very complex so I didn't want to put it all here, but if someone needs a better explanation to what I'm finding I can provide a full example.

    Thanks!!!

  • I think I saw fixes in that area in 1.6/develop. Could you check that version of the ORM package (should work fine with a 1.5.3 core)?

    If not already fixed, please create an issue for this at https://github.com/fuel/orm/issues.

Howdy, Stranger!

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

In this Discussion