All pastes #280072 Raw Edit

Tangram

public php v1 · immutable
·published 2006-12-15 16:52 UTC
rendered paste body
$items = array('A', 'B', 'C', 'D');/* Database contains any letters between A..Z. Could contain none, all, or any combination of letters, no duplication */// Is it more efficient to:foreach ($items as $item){	$sql = "SELECT 1		FROM letters		WHERE letter = $item";	$result_set = $dbObj->execute_query($sql);	if (!$dbObj->get_num_rows($result_set))	{		// item is not in the database		// ...	}}// ... or ...$sql = "SELECT letter	FROM letters";$result_set = $dbObj->execute_query($sql);$item_array = $dbObj->get_row_array($result_set);foreach ($items as $item){	if (!in_array($item, $item_array))	{		// item is not in database		// ...	}}