Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Maximum execution time of 30 seconds exceeded
  • I'm trying to get a relatively simple site going but i am receiving a fairly cryptic error. I'm trying to get a list of users back from my database and parse them through a view. All the orm stuff seems to work and the data is bought back, but as soon as the data is passed to view
    return View::factory('dashboard/users', $data);
    

    I get "Maximum execution time of 30 seconds exceeded". I can't figure out why this won't work, it seems to be a problem with the $data thats being passed into the view as it works when no data parameter is specified. I've included the model, controller, and view code bellow. Any insight would be much appreciated!
    Model
    <?php
    
    class Model_Sites extends Orm\Model &#123; 
    
     protected static $_many_many = array(
         'users' => array(
             'key_from' => 'id',
             'key_through_from' => 'site_id', // column 1 from the table in between, should match a posts.id
             'table_through' => 'sites_users', // both models plural without prefix in alphabetical order
             'key_through_to' => 'user_id', // column 2 from the table in between, should match a users.id
             'model_to' => 'Model_Users',
             'key_to' => 'id',
             'cascade_save' => true,
             'cascade_delete' => false,
         )
     );
     
    }
    
    /* End of file sites.php */
    

    Controller
    <?php
    
    class Controller_Dashboard extends Controller_Template &#123;
     
     private $user = NULL;
     
     public function action_index()
     &#123;
      $data['sites'] = $this->list_sites();
      $site = current($this->user->sites);
      Session::set("sites",$site);
      if ($site instanceof Model_Sites)
      &#123;
       $data['users'] = $this->list_users($site->id);
      }
      $this->template->title = 'Dashboard » Index';
      $this->template->content = View::factory('dashboard/index', $data);  
     }
     
     
     public function before()
     &#123;
      Session::instance();
      $auth = Auth::instance();
      if (!$auth->perform_check())
      &#123;
       Session::set_flash('notice', 'Please log in to see this page');
    
       Response::redirect('welcome');
      }
      
      $this->user = Model_Users::find()
          ->related('sites')
          ->where('username', '=', \Session::get('username'))
          ->get_one();
      parent::before();
     }
     
     public function list_sites()
     &#123;
      if (empty($this->user->sites))
      &#123;
       return "";
      }
      $data['sites'] = $this->user->sites;
      return View::factory('sites/index', $data);
     }
     
     public function list_users($site_id)
     &#123;
      $site = Model_Sites::find()
          ->related('users')
          ->where('id', '=', $site_id)
          ->get_one();
          
      $data['users'] = $site->users;
    
      if (empty($site->users))
      &#123;
       $data['users'] = "";
      }
      
      return View::factory('dashboard/users', $data);
     }
     
    }
    
    /* End of file dashboard.php */
    

    View
    <div id="users">
     
     <table>
      <tr>
       <th>Username</th>
       <th>Email</th>
       <th></th>
       <th></th>
       <th></th>
      </tr>
    
      <?php foreach ($users as $simpleusers): ?> <tr>
       <td><?php echo $simpleusers->username; ?></td>
       <td><?php echo $simpleusers->email; ?></td>
       <td><?php echo Html::anchor('users/view/'.$simpleusers->id, 'View'); ?></td>
       <td><?php echo Html::anchor('users/edit/'.$simpleusers->id, 'Edit'); ?></td>
       <td><?php echo Html::anchor('users/delete/'.$simpleusers->id, 'Delete', array('onclick' => "return confirm('Are you sure?')")); ?></td>
      </tr>
      <?php endforeach; ?></table>
      
    </div>
    
  • Thanks for the tip Syntaqx, unfortunately I still get the same error. Here it is in a bit more detail:
    Error!
    ErrorException [ Error ]: Maximum execution time of 30 seconds exceeded
    
    PKGPATH/orm/classes/model.php @ line 689
    
    684            throw new FrozenObject('No changes allowed.');
    685        }
    686
    687        if (in_array($property, static::primary_key()) and $this->&#123;$property} !== null)
    688        &#123;
    689            throw new \Fuel_Exception('Primary key cannot be changed.');
    690        }
    691        if (array_key_exists($property, static::properties()))
    692        &#123;
    693            $this->_data[$property] = $value;
    694        }
    Backtrace
    
    COREPATH/base.php @ line 182
    177
    178if ( ! function_exists('fuel_shutdown_handler'))
    179&#123;
    180    function fuel_shutdown_handler()
    181    &#123;
    182        return \Error::shutdown_handler();
    183    }
    184}
    185
    186if ( ! function_exists('fuel_exception_handler'))
    187&#123;
    

    And here is what my models now look like:
    <?php
    
    class Model_Sites extends Orm\Model &#123; 
    
     protected static $_many_many = array(
         'users' => array(
             'key_from' => 'id',
             'key_through_from' => 'site_id', // column 1 from the table in between, should match a posts.id
             'table_through' => 'sites_users', // both models plural without prefix in alphabetical order
             'key_through_to' => 'user_id', // column 2 from the table in between, should match a users.id
             'model_to' => 'Model_Users',
             'key_to' => 'id',
             'cascade_save' => true,
             'cascade_delete' => false,
         )
     );
     
     protected static $_properties = array(
      'id',
      'name',
      'url',
      'unique_id'
     );
    }
    
    /* End of file sites.php */
    

    and
    <?php
    
    class Model_Users extends Orm\Model &#123; 
    
     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 posts.id
             '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 users.id
             'model_to' => 'Model_Sites',
             'key_to' => 'id',
             'cascade_save' => true,
             'cascade_delete' => false,
         )
     );
     
     protected static $_properties = array(
      'id',
      'username',
      'password',
      'group',
      'email',
      'last_login',
      'login_hash',
      'profile_fields'
     );
    }
    
    /* End of file simpleusers.php */
    

Howdy, Stranger!

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

In this Discussion