All pastes #802661 Raw Edit

Something

public text v1 · immutable
#802661 ·published 2007-11-30 14:56 UTC
rendered paste body
$criteria = preg_replace('%[^a-z]+%i', ' ', $criteria);
		$criteria = array_unique(explode(' ', $criteria));

		$wheres = array();
		$params = array();

		foreach($criteria as $crit) 
		{
			$wheres[] = '(jobNum LIKE ? OR requestor LIKE ?
						OR completedBy LIKE ? OR checkedBy LIKE ?
						OR sourceName LIKE ?
						)';
			$params = array_merge($params, array_fill(0, 5, $crit));
		}
		
		$where = implode(' AND ', $wheres);
		$sql = 'FROM dubReqs WHERE ' . $where;
		            		
		$count = DB::instance()->value(
				'SELECT count(*) ' . $sql, $params,
				'Dubs'
				);
				
        $results = DB::instance()->results(
				'SELECT * ' . $sql . ' LIMIT ' . $limit, $params, 
				'Dubs'
				);