protected function _importRecords($fixtureClassName, TableSchema $schema, Connection $connection)
    {
        $fixture = new $fixtureClassName;
        if (!isset($fixture->records) || empty($fixture->records)) {
            return true;
        }

        $fixture->records = (array)$fixture->records;
        if (count($fixture->records) > 100) {
            $chunk = array_chunk($fixture->records, 100);
        } else {
            $chunk = [0 => $fixture->records];
        }

        foreach ($chunk as $records) {
            list($fields, $values, $types) = $this->_getRecords($records, $schema);
            $query = $connection->newQuery()
                ->insert($fields, $types)
                ->into($schema->name());

            foreach ($values as $row) {
                $query->values($row);
            }

            try {
                $statement = $query->execute();
                $statement->closeCursor();
            } catch (\Exception $ex) {
                $this->error(__d('installer', 'Error while importing data for table "{0}". Details: {1}', $schema->name(), $ex->getMessage()));

                return false;
            }
        }

        return true;
    }
protected function _importRecords($fixtureClassName, TableSchema $schema, Connection $connection)
    {
        $fixture = new $fixtureClassName;
        if (!isset($fixture->records) || empty($fixture->records)) {
            return true;
        }

        $fixture->records = (array)$fixture->records;
        if (count($fixture->records) > 100) {
            $chunk = array_chunk($fixture->records, 100);
        } else {
            $chunk = [0 => $fixture->records];
        }

        foreach ($chunk as $records) {
            list($fields, $values, $types) = $this->_getRecords($records, $schema);
            $query = $connection->newQuery()
                ->insert($fields, $types)
                ->into($schema->name());

            foreach ($values as $row) {
                $query->values($row);
            }

            try {
                $statement = $query->execute();
                $statement->closeCursor();
            } catch (\Exception $ex) {
                $this->error(__d('installer', 'Error while importing data for table "{0}". Details: {1}', $schema->name(), $ex->getMessage()));

                return false;
            }
        }

        return true;
    }
protected function _importRecords ( $ fixtureClassName , TableSchema $ schema , Connection $ connection ) { $ fixture = new $ fixtureClassName ; if ( ! isset ( $ fixture -> records ) || empty ( $ fixture -> records ) ) { return true ; } $ fixture -> records = ( array ) $ fixture -> records ; if ( count ( $ fixture -> records ) > 100 ) { $ chunk = array_chunk ( $ fixture -> records , 100 ) ; } else { $ chunk = [ 0 => $ fixture -> records ] ; } foreach ( $ chunk as $ records ) { list ( $ fields , $ values , $ types ) = $ this -> _getRecords ( $ records , $ schema ) ; $ query = $ connection -> newQuery ( ) -> insert ( $ fields , $ types ) -> into ( $ schema -> name ( ) ) ; foreach ( $ values as $ row ) { $ query -> values ( $ row ) ; } try { $ statement = $ query -> execute ( ) ; $ statement -> closeCursor ( ) ; } catch ( \ Exception $ ex ) { $ this -> error ( __d ( 'installer' , 'Error while importing data for table "{0}". Details: {1}' , $ schema -> name ( ) , $ ex -> getMessage ( ) ) ) ; return false ; } } return true ; }
Imports all records of the given fixture.

@param string $fixtureClassName Fixture class name
@param \Cake\Database\Schema\Table $schema Table schema for which records
will be imported
@param \Cake\Database\Connection $connection Database connection to use
@return bool True on success
Imports all records of the given fixture .