1

How to run following sql by RedBean?

INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);

Should I use loop or RedBean support batch insert?

Moein Hosseini
  • 4,309
  • 15
  • 68
  • 106
  • 1
    Please take a look at this question -> http://stackoverflow.com/questions/12786605/how-to-bulk-insert-with-redbeanphp – Dave Chen Aug 24 '13 at 08:14

2 Answers2

5

Creator of RedBeanPHP here.

This is not supported by RedBeanPHP. You will have to use plain old SQL for this.

Gabor de Mooij
  • 2,997
  • 17
  • 22
2

What about sample logic?:

    $list = array(1, 2, 3, 4, 5, 6, 7, 8, 9);

    $beans = R::dispense('table', count($list));

    for($i=0; $i<count($list)/3; $i++)
    {
        $beans[$i]->a = $list[$i*3+1];
        $beans[$i]->b = $list[$i*3+2];
        $beans[$i]->c = $list[$i*3+3];
    }

    R::storeAll($beans);
Marius
  • 399
  • 2
  • 14