How do I add more than one row with Zend_Db?

前端 未结 6 885
暗喜
暗喜 2020-12-08 07:57

I have an array with information which looks more or less like this:

$data[] = array(\'content\'=>\'asd\');
$data[] = array(\'content\'=>\'asdf\');
         


        
6条回答
  •  难免孤独
    2020-12-08 08:54

    It's work.

     $query = 'INSERT INTO ' . $db->quoteIdentifier('table') . ' (`col1`, `col2`) VALUES ';
        $queryVals = array();
        foreach ($data as $row) {
            foreach($row as &$col) {
                $col = $db->quote($col);
            }
            $queryVals[] = '(' . implode(',', $row) . ')';
        }
        $stmt = $db->query($query . implode(',', $queryVals));
    

    how to build multiple insert query in zend framework

提交回复
热议问题