Skip to content

INSERT INTO SELECT #171

@matak

Description

@matak
  • bug report? yes
  • feature request? no
  • version: ~2.3@dev

Description


$database->query("
				INSERT INTO product_stock_merchant_events (x, y, z)
				SELECT 
				x, y, z
				FROM product_stock_events 
				WHERE id IN (?)", 
				$stockEvent_ids);

when you try to call insert with select it crashes on

Invalid argument supplied for foreach()


File: ...\nette\database\src\Database\SqlPreprocessor.php:178

168:            }
169:    
170:            if (is_array($value)) {
171:                $vx = $kx = array();
172:                if ($mode === 'auto') {
173:                    $mode = $this->arrayMode;
174:                }
175:    
176:                if ($mode === 'values') { // (key, key, ...) VALUES (value, value, ...)
177:                    if (array_key_exists(0, $value)) { // multi-insert
178:                        foreach ($value[0] as $k => $v) {
179:                            $kx[] = $this->delimite($k);
180:                        }
181:                        foreach ($value as $val) {
182:                            $vx2 = array();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions