Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Database_Query_Builder_Delete error
  • Hi again! When I delete a many to many relationship I get this bug coming up: ErrorException [ Error ]: Call to undefined method Fuel\Core\Database_Query_Builder_Delete::delete()
    PKGPATH/orm/classes/manymany.php @ line 292

    287            next($this->key_from);
    288        }
    289        \Debug::dump($query);
    290        \Debug::backtrace();
    291        //die();
    292        $query->delete();
    294        $cascade = is_null($cascade) ? $this->cascade_delete : (bool) $cascade;
    295        if ($cascade and ! empty($model_to))
    296        {
    297            foreach ($models_to as $m)

    The model code is:
    class Model_Users extends Orm\Model { 
     protected static $_many_many = array(
         'sites' => array(
             'key_from' => 'id',
             'key_through_from' => 'user_id', // column 1 from the table in between, should match a
             'table_through' => 'sites_users', // both models plural without prefix in alphabetical order
             'key_through_to' => 'site_id', // column 2 from the table in between, should match a
             'model_to' => 'Model_Sites',
             'key_to' => 'id',
             'cascade_save' => true,
             'cascade_delete' => false,

    And the code for deletion is the code from the scafolding:
    public function action_delete($id = null)
      if ($users = Model_Users::find($id))
       Session::set_flash('notice', 'Deleted user #' . $id);
       Session::set_flash('notice', 'Could not delete user #' . $id);

    Finally, here is a debug dump of the Database_Query_Builder_Delete object:
    object(Fuel\Core\Database_Query_Builder_Delete)#13 (9) {
      string(11) "sites_users"
      array(1) {
        array(1) {
          array(3) {
            string(7) "user_id"
            string(1) "="
            string(1) "6"
      array(0) {
      string(0) ""
      array(0) {

    Anyone have any ideas? I've spent an hour or so trying to figure it out, so sorry if it's something straight forward I've missed. It's been a long day! Cheers,
  • This has been fixed in the dev branch and will be in the next release.
  • Again, thanks for the speedy response! Thats good news it's been fixed! Thought I was going crazy! Any time frame on the next release? Or is the dev branch stable enough to use?
  • Next release (RC3) should be soon, it's almost ready to be called final (lack of a hell of a lot of core unit tests is preventing that from happening soon). There's not much holding up the next release, no experimental stuff in the dev branch currently but a hell of a lot of bugfixes - so it's probably more stable right now.

Howdy, Stranger!

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

In this Discussion