pixie icon indicating copy to clipboard operation
pixie copied to clipboard

onDuplicateKeyUpdate & Batch Insert (array of arrays)

Open zlodes opened this issue 10 years ago • 4 comments

I have an error

SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'field list'.

Trying to batch insert and onDuplicateKeyUpdate with data like array of arrays.

This array:

Array
(
    [0] => Array
        (
            [module] => groups
            [method] => access
            [level] => 1
            [user_id] => 4
        )

    [1] => Array
        (
            [module] => groups
            [method] => add
            [level] => 3
            [user_id] => 4
        )

    [2] => Array
        (
            [module] => groups
            [method] => del
            [level] => 3
            [user_id] => 4
        )
)

zlodes avatar Oct 21 '15 10:10 zlodes

Sorry for the delay. Can you please show me your code?

usmanhalalit avatar Dec 08 '15 06:12 usmanhalalit

There is my code:

        $data_array = array(
            array(
                "module" => "groups",
                "method" => "access",
                "level" => 1,
                "user_id" => 4
            ),
            array(
                "module" => "groups",
                "method" => "add",
                "level" => 3,
                "user_id" => 4
            ),
            array(
                "module" => "groups",
                "method" => "del",
                "level" => 3,
                "user_id" => 4
            )
        );

        QB::table('groups_access')
            ->onDuplicateKeyUpdate($data_array)
            ->insert($data_array);

Update or Insert works fine, but batch insert on DuplicateKeyUpdate not working.

zlodes avatar Dec 08 '15 16:12 zlodes

This seems like a bug. Cannot give any ETA for the fix.

usmanhalalit avatar Dec 25 '15 11:12 usmanhalalit

I've just pushed up onto: https://github.com/madebymagnitude/pixie

Which has a patch for working with batch onDuplicateKeyUpdate.

LewisTheobald avatar May 09 '16 13:05 LewisTheobald