Пример #1
0
 public function batchInsert($table, array $data)
 {
     if (empty($data)) {
         return false;
     }
     $sql = SqlBuilder::buildInsertSql($table, $data[0]);
     $stmt = $this->_dao->prepare($sql);
     try {
         $this->beginTransaction();
         foreach ($data as $row) {
             $params = $this->buildParams($row);
             $this->bindParams($stmt, $params);
             $stmt->execute();
         }
         $this->commit();
         return $stmt->affected_rows;
     } catch (\Exception $e) {
         $this->rollback();
         return false;
     }
 }
Пример #2
0
 public function batchInsert($table, array $data)
 {
     if (empty($data)) {
         return false;
     }
     $sql = SqlBuilder::buildInsertSql($table, $data[0]);
     $stmt = $this->_dao->prepare($sql);
     try {
         $this->begin_transaction();
         foreach ($data as $row) {
             $params = array_values($row);
             $stmt->execute($params);
         }
         $this->commit();
         return true;
     } catch (Exception $e) {
         $this->rollback();
     }
     return false;
 }