Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
ORM not working?
  • Hello everyone, Im new here and i just started trying to use fuelphp and im trying to use ORM. In the config ive setted: 'packages' => array(
    ), The controller: class Controller_Article extends Controller { public function action_index()
    { $data = Model_Article::find('all'); echo '<pre>'.$data.'</pre>'; $this->response->body = View::factory('articles/index', $data);
    } The model: class Model_Article extends Orm\Model
    protected static $_properties = array('id', 'title', 'content', 'date');
    protected static $_primary_key = array('id');
    protected static $_table_name = 'articles';
    } //Formatting in the editor didn't work for me... OSX Firefox 5. It's giving me an empty array, i also turned on full logging and the log file is empty.
    Am i doing something wrong?
  • Are you sure there's any data in your table? All of this looks fine.
  • Yes im sure. Im running everything in a vhost with mamp on osx.
    Maybe the problem in there?
  • Doubt it, many will have similar test setups.
  • Try this instead: Model_Article::query()->get(), if that does work there's a weird problem. And if that doesn't work: echo Model_Article::query()->get_query() - it will return a database_query object but when you echo it it will output as an SQL query, which you can check for faults.
  • SELECT `t0`.`id` AS `t0_c0`, `t0`.`title` AS `t0_c1`, `t0`.`content` AS `t0_c2`, `t0`.`date` AS `t0_c3` FROM `articles` AS `t0` when i use the query in phpmyadmin it's giving me the results.
    So yeah something strange is going on...
  • this is my database setup Fuel:: DEVELOPMENT => array(
    'type' => 'mysql',
    'connection' => array(
    'hostname' => '',
    'database' => 'ryatzu',
    'username' => 'root',
    'password' => 'root',
    'persistent' => false,
    'table_prefix' => '',
    'charset' => 'utf8',
    'caching' => false,
    'profiling' => false,
  • Ok i have copied the whole project over to my own web server.
    And im still having the same problem.

Howdy, Stranger!

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

In this Discussion