src/SqlStatement.php
public static function toValues($input, array $include = [])
	{
		if (!is_array($input) && !is_object($input)) {
			throw new InvalidArgumentException('input must be an associative array or traversable object');
		}

		$sqlStrs = [];

		if (count($include)) {
			foreach ($include as $i) {
				if (array_key_exists($i, $input)) {
					$sqlStrs[] = '`' . $i . '` = VALUES(`' . $i . '`)';
				}
			}
		}
		else {
			foreach ($input as $k => &$v) {
				$sqlStrs[] = '`' . $k . '` = VALUES(`' . $k . '`)';
			}
		}

		return implode(",\n", $sqlStrs);
	}
public static function toValues($input, array $include = [])
	{
		if (!is_array($input) && !is_object($input)) {
			throw new InvalidArgumentException('input must be an associative array or traversable object');
		}

		$sqlStrs = [];

		if (count($include)) {
			foreach ($include as $i) {
				if (array_key_exists($i, $input)) {
					$sqlStrs[] = '`' . $i . '` = VALUES(`' . $i . '`)';
				}
			}
		}
		else {
			foreach ($input as $k => &$v) {
				$sqlStrs[] = '`' . $k . '` = VALUES(`' . $k . '`)';
			}
		}

		return implode(",\n", $sqlStrs);
	}
public static function toValues ( $ input , array $ include = [ ] ) { if ( ! is_array ( $ input ) && ! is_object ( $ input ) ) { throw new InvalidArgumentException ( 'input must be an associative array or traversable object' ) ; } $ sqlStrs = [ ] ; if ( count ( $ include ) ) { foreach ( $ include as $ i ) { if ( array_key_exists ( $ i , $ input ) ) { $ sqlStrs [ ] = '`' . $ i . '` = VALUES(`' . $ i . '`)' ; } } } else { foreach ( $ input as $ k => & $ v ) { $ sqlStrs [ ] = '`' . $ k . '` = VALUES(`' . $ k . '`)' ; } } return implode ( ",\n" , $ sqlStrs ) ; }
Returns a string formatted for an SQL
"ON DUPLICATE KEY UPDATE" statement.

Accepts an associative array or Traversable object and
an array where the values are the names of the desired keys.
An empty "include" array means to use all.

@param array|\stdClass $input
@param array           $include

@return string
Returns a string formatted for an SQL ON DUPLICATE KEY UPDATE statement .