public function flushQueue($table, $onduplicate = null) {
		if (gettype($table) != 'string') {
			throw new Exception('First parameter should be string, ' . gettype($table) . ' given.');
		}
		if (isset($this->queue[$table]) && $this->queue[$table]) {
			// Define query
			$query = "INSERT INTO `" . $table . "` (`" . implode("`,`", array_keys($this->queue[$table][0])) . "`) VALUES ";
			
			// Count number of parameters in element
			$prefixOuter = '';
			$rowPlaces = '';
			foreach ($this->queue[$table] as $entry) {
				$prefixInner = '';
				$rowPlaces .= $prefixOuter . '(';
				foreach ($entry as $column) {
					if (is_object($column) && $column instanceof PdoBulkSubquery) {
						$rowPlaces .= $prefixInner . '(' . $column->getQuery() . ')';
					} else {
						$rowPlaces .= $prefixInner . '?';
					}
					$prefixInner = ',';
				}
				$rowPlaces .= ')';
				$prefixOuter = ',';
			}
			
			$query .= $rowPlaces;
			if ($onduplicate && gettype($onduplicate) == 'string') {
				$query .= ' ' . $onduplicate;
			}
			
			$stmt = $this->getPdo()->prepare($query);
			
			// Prepare binding values for execution
			$values = array();
			foreach ($this->queue[$table] as $entry) {
				foreach ($entry as $column_name => $column_value) {
					if (is_object($column_value) && $column_value instanceof PdoBulkSubquery) {
						unset($entry[$column_name]);
					}	
				}
				$values = array_merge($values, array_values($entry));
			}
			
			$stmt->execute($values);
			$this->queue[$table] = array();
			return true;
		} else {
			return false;
		}
	}
public function flushQueue($table, $onduplicate = null) {
		if (gettype($table) != 'string') {
			throw new Exception('First parameter should be string, ' . gettype($table) . ' given.');
		}
		if (isset($this->queue[$table]) && $this->queue[$table]) {
			// Define query
			$query = "INSERT INTO `" . $table . "` (`" . implode("`,`", array_keys($this->queue[$table][0])) . "`) VALUES ";
			
			// Count number of parameters in element
			$prefixOuter = '';
			$rowPlaces = '';
			foreach ($this->queue[$table] as $entry) {
				$prefixInner = '';
				$rowPlaces .= $prefixOuter . '(';
				foreach ($entry as $column) {
					if (is_object($column) && $column instanceof PdoBulkSubquery) {
						$rowPlaces .= $prefixInner . '(' . $column->getQuery() . ')';
					} else {
						$rowPlaces .= $prefixInner . '?';
					}
					$prefixInner = ',';
				}
				$rowPlaces .= ')';
				$prefixOuter = ',';
			}
			
			$query .= $rowPlaces;
			if ($onduplicate && gettype($onduplicate) == 'string') {
				$query .= ' ' . $onduplicate;
			}
			
			$stmt = $this->getPdo()->prepare($query);
			
			// Prepare binding values for execution
			$values = array();
			foreach ($this->queue[$table] as $entry) {
				foreach ($entry as $column_name => $column_value) {
					if (is_object($column_value) && $column_value instanceof PdoBulkSubquery) {
						unset($entry[$column_name]);
					}	
				}
				$values = array_merge($values, array_values($entry));
			}
			
			$stmt->execute($values);
			$this->queue[$table] = array();
			return true;
		} else {
			return false;
		}
	}
public function flushQueue ( $ table , $ onduplicate = null ) { if ( gettype ( $ table ) != 'string' ) { throw new Exception ( 'First parameter should be string, ' . gettype ( $ table ) . ' given.' ) ; } if ( isset ( $ this -> queue [ $ table ] ) && $ this -> queue [ $ table ] ) { // Define query $ query = "INSERT INTO `" . $ table . "` (`" . implode ( "`,`" , array_keys ( $ this -> queue [ $ table ] [ 0 ] ) ) . "`) VALUES " ; // Count number of parameters in element $ prefixOuter = '' ; $ rowPlaces = '' ; foreach ( $ this -> queue [ $ table ] as $ entry ) { $ prefixInner = '' ; $ rowPlaces .= $ prefixOuter . '(' ; foreach ( $ entry as $ column ) { if ( is_object ( $ column ) && $ column instanceof PdoBulkSubquery ) { $ rowPlaces .= $ prefixInner . '(' . $ column -> getQuery ( ) . ')' ; } else { $ rowPlaces .= $ prefixInner . '?' ; } $ prefixInner = ',' ; } $ rowPlaces .= ')' ; $ prefixOuter = ',' ; } $ query .= $ rowPlaces ; if ( $ onduplicate && gettype ( $ onduplicate ) == 'string' ) { $ query .= ' ' . $ onduplicate ; } $ stmt = $ this -> getPdo ( ) -> prepare ( $ query ) ; // Prepare binding values for execution $ values = array ( ) ; foreach ( $ this -> queue [ $ table ] as $ entry ) { foreach ( $ entry as $ column_name => $ column_value ) { if ( is_object ( $ column_value ) && $ column_value instanceof PdoBulkSubquery ) { unset ( $ entry [ $ column_name ] ) ; } } $ values = array_merge ( $ values , array_values ( $ entry ) ) ; } $ stmt -> execute ( $ values ) ; $ this -> queue [ $ table ] = array ( ) ; return true ; } else { return false ; } }
Bulk insert logic
Bulk insert logic