Ejemplo n.º 1
0
 protected function insertRows()
 {
     $rowsToInsert = (int) Request::get('rows');
     $insertedCnt = 0;
     for ($i = 0; $i < $rowsToInsert; $i++) {
         $params = array_merge($this->insDefaults, $this->where);
         $paramValues = null;
         if (Cfg::get('jb_db', false)) {
             $params[$this->primaryKey] = DBMaintenance::dbNextNumber($this->db, $this->tableName);
         }
         $sql = 'INSERT INTO ' . $this->tableName;
         if (count($params) > 0) {
             $sql .= ' (' . join(',', array_keys($params)) . ') ' . 'VALUES (' . DB::in(array_values($params), $paramValues) . ')';
         }
         $insertedCnt += $this->exec($sql, $paramValues);
     }
     if ($insertedCnt > 0) {
         $this->paginator->setRows($this->getRowCount());
     }
     return 'Inserted ' . $insertedCnt . ' row' . StringUtil::plural($insertedCnt) . Tag::br();
 }