Skip to content

Instantly share code, notes, and snippets.

@cornernote
cornernote / README.md
Last active August 29, 2015 14:23
Yii2 batchInsert

I am using batchInsert to insert bulk data, but its inserting in the wrong order in php5.4 (php5.5+ is fine).

I found the reason, but dont understand where Yii2 is doing this...

I am looking at the source for batchInsert (https://github.com/yiisoft/yii2/blob/master/framework/db/QueryBuilder.php#L181), and I dont understand how it's doing the unions.. i cant see code for that anywhere

PHP 5.4

INSERT INTO `audit_trail` (`audit_id`, `user_id`, `old_value`, `new_value`, `action`, `model`, `model_id`, `field`, `stamp`) 
SELECT NULL, NULL, '', '4', 'CREATE', 'tests\models\Post', '4', 'id', '2015-06-22 15:02:38' 
root@test:/vagrant/git/yii2-audit/tests# ../vendor/bin/codecept run
Codeception PHP Testing Framework v2.0.14
Powered by PHPUnit 4.6.10 by Sebastian Bergmann and contributors.
Bedezign\yii2\audit\tests.functional Tests (1) ----------------------------------------------------------------------
Ensure that home page works (HomeCept) Error
---------------------------------------------------------------------------------------------------------------------
Bedezign\yii2\audit\tests.unit Tests (0) ----
---------------------------------------------

$ ../vendor/bin/codecept build

Building Actor classes for suites: functional, unit
bedezign\yii2\audit\tests\FunctionalTester includes modules: Yii2, tests\codeception\_support\FixtureHelper, tests\codeception\_support\MailHelper
FunctionalTester.php generated successfully. 54 methods added
bedezign\yii2\audit\tests\UnitTester includes modules: Asserts, tests\codeception\_support\CodeHelper
UnitTester.php generated successfully. 19 methods added
<?php
namespace bedezign\yii2\audit\tests;
use app\models\Post;
use Codeception\Specify;
use yii\codeception\TestCase;
/**
* AuditTrailBehaviorTest
<?php
namespace bedezign\yii2\audit\components;
use bedezign\yii2\audit\models\AuditTrail;
use yii\base\Component;
use yii\db\ActiveRecord;
/**
* Version
* @package bedezign\yii2\audit
root@test:/vagrant/git/yii2-audit# git push heroku master
Counting objects: 5, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 368 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> PHP app detected
remote: -----> Resolved composer.lock requirement for PHP to version 5.6.11.
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
# private network (replace XXX)
<?php
class m150719_043333_audit extends \yii\db\Migration
{
public function safeUp()
{
$query = <<<SQL
CREATE SCHEMA audits
SQL;
$this->execute($query);
-- remove flowing
minetest.register_abm({
nodenames = {'default:lava_flowing','default:water_flowing'},
interval = 1,
chance = 1,
action = function(pos, node)
if pos.y < skyblock.WORLD_BOTTOM then
minetest.env:remove_node(pos)
end
end,
# This file contains settings of skyblock that can be changed in
# minetest.conf
#
# By default, all the settings are commented and not functional.
# Uncomment settings by removing the preceding #.
# How far apart to set players start positions
#skyblock.start_gap = 32
# The Y position the spawn nodes will appear