public function sqlInsertMultiple(
		$into,
		array $properties,
		$replace = false
	) {
		if ($replace) {
			$sql = 'REPLACE';
		} else {
			$sql = 'INSERT';
		}
		$insert_values = [];
		$attributes = array_shift($properties);
		$count = count($attributes);
		$sql .= ' INTO ' . $into . ' (' . implode(', ', $attributes) . ') VALUES ';
		foreach ($properties as $i => $props) { // for all entries
			if (count($props) !== $count) {
				throw new Exception('Missing property value(s) for entry: ' . $i);
			}
			if ($i > 0) {
				$sql .= ', ';
			}
			$sql .= '(';
			foreach ($props as $j => $value) {
				$param = ':I' . $i . $attributes[$j]; // name parameters after attribute with index
				$insert_values[$param] = $value;
				if ($j > 0) {
					$sql .= ', ';
				}
				$sql .= $param;  // named params
			}
			$sql .= ')';
		}
		$query = $this->database->prepare($sql);
		$query->execute($insert_values);
		$this->addQuery($query->queryString, $insert_values);
		return $query->rowCount();
	}
public function sqlInsertMultiple(
		$into,
		array $properties,
		$replace = false
	) {
		if ($replace) {
			$sql = 'REPLACE';
		} else {
			$sql = 'INSERT';
		}
		$insert_values = [];
		$attributes = array_shift($properties);
		$count = count($attributes);
		$sql .= ' INTO ' . $into . ' (' . implode(', ', $attributes) . ') VALUES ';
		foreach ($properties as $i => $props) { // for all entries
			if (count($props) !== $count) {
				throw new Exception('Missing property value(s) for entry: ' . $i);
			}
			if ($i > 0) {
				$sql .= ', ';
			}
			$sql .= '(';
			foreach ($props as $j => $value) {
				$param = ':I' . $i . $attributes[$j]; // name parameters after attribute with index
				$insert_values[$param] = $value;
				if ($j > 0) {
					$sql .= ', ';
				}
				$sql .= $param;  // named params
			}
			$sql .= ')';
		}
		$query = $this->database->prepare($sql);
		$query->execute($insert_values);
		$this->addQuery($query->queryString, $insert_values);
		return $query->rowCount();
	}
public function sqlInsertMultiple ( $ into , array $ properties , $ replace = false ) { if ( $ replace ) { $ sql = 'REPLACE' ; } else { $ sql = 'INSERT' ; } $ insert_values = [ ] ; $ attributes = array_shift ( $ properties ) ; $ count = count ( $ attributes ) ; $ sql .= ' INTO ' . $ into . ' (' . implode ( ', ' , $ attributes ) . ') VALUES ' ; foreach ( $ properties as $ i => $ props ) { // for all entries if ( count ( $ props ) !== $ count ) { throw new Exception ( 'Missing property value(s) for entry: ' . $ i ) ; } if ( $ i > 0 ) { $ sql .= ', ' ; } $ sql .= '(' ; foreach ( $ props as $ j => $ value ) { $ param = ':I' . $ i . $ attributes [ $ j ] ; // name parameters after attribute with index $ insert_values [ $ param ] = $ value ; if ( $ j > 0 ) { $ sql .= ', ' ; } $ sql .= $ param ; // named params } $ sql .= ')' ; } $ query = $ this -> database -> prepare ( $ sql ) ; $ query -> execute ( $ insert_values ) ; $ this -> addQuery ( $ query -> queryString , $ insert_values ) ; return $ query -> rowCount ( ) ; }
Requires positional parameters.

@param string $into
@param string[][] $properties =
[
["attr_name1", "attr_name2", ...],
["entry1value1", "entry1value2", ...],
["entry2value1", "entry2value2", ...],
...
]
@param boolean $replace DELETE & INSERT if primary key already exists
@return int number of rows affected
@throws Exception if number of values !== number of properties
Requires positional parameters .