Jump to content

Chunk select with redbean


weraw

Recommended Posts

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 NULL
This 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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.