Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Using DB without where() causes error
  • I'm trying to run something along the lines of DB::select(array('img_url', 'title_html'))->from('adverts')->order_by(DB::expr('RAND()'))->limit(1)->execute(); However, it returns ErrorException [ Warning ]: mysql_data_seek() expects parameter 2 to be long, string given It appears that if I add a where() the error goes away. But I don't want to use a where(). Any ideas?
  • So the where() might not have anything to do with it, the error returns when more than 0 rows are returned.
  • So here's a printout of what the object returns object(Fuel\Core\Database_MySQL_Result)#35 (6) {
    ["_internal_row":protected]=>
    int(0)
    ["_query":protected]=>
    string(71) "SELECT * FROM `adverts` WHERE `start` < NOW() AND `end` > NOW() LIMIT 1"
    ["_result":protected]=>
    resource(65) of type (mysql result)
    ["_total_rows":protected]=>
    int(1)
    ["_current_row":protected]=>
    int(0)
    ["_as_object":protected]=>
    bool(false)
    }
  • Are you sure you're getting the error on the execute() itself? You get this error when a non-numeric offset is requested. After the query the result is positioned on _current_row, which is int(0) according to your dump. Otherwise add a debug to core/classes/database/mysql/result.php, line 36 (in 1.1/develop), to see what the value of $offset is.

Howdy, Stranger!

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

In this Discussion