weraw Posted November 28, 2013 Share Posted November 28, 2013 Hello, I have been starded using redbean. I have a really big table and want to select 5000 rows at time using redbean!I want only the rows where the field "status" IS NULLThis is my code: $min = R::$c->begin()->addSQL('SELECT MIN(id)')->from('emailtable')->get('cell'); $max = R::$c->begin()->addSQL('SELECT MAX(id)')->from('emailtable')->get('cell'); for ($i = $min; $i < $max; $i = $i + 5000) { $x = $i; $y = $i + 5000; $select = R::$c->begin() ->addSQL(' SELECT * ') ->from('emailtable') ->where(" id >= ? AND id < ? AND status IS NULL ") ->put($x) ->put($y) ->get(); } Anyone know if this is the right way to go! Should i use: id >= ? AND id < ? AND status IS NULL or maybe i should use BETWEEN but not sure. My problem is The code above is sometimes selecting same id twice and that is what i do not expect! there for i ask if there is a other solution four the code above! All ides are welcome. It is really hard to find information about redbean/chunk/select/ example Link to comment https://forums.phpfreaks.com/topic/284370-chunk-select-with-redbean/ Share on other sites More sharing options...
weraw Posted December 1, 2013 Author Share Posted December 1, 2013 anyone? Link to comment https://forums.phpfreaks.com/topic/284370-chunk-select-with-redbean/#findComment-1460897 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.