function prefixQuery( $regex, $query, $prefix = NULL ) {
		if( !isset( $prefix ) ) {
			return $query;
		}

		if( preg_match( $regex, $query, $match ) ) {
			$preamble = $match[1];
			$postamble = $match[5];
			$objectList = explode( ',', $match[3] );
			// $prefix = $prefix . '_';

			$prefixedList = '';

			foreach( $objectList as $object ) {
				if( $prefixedList !== '' ) {
					$prefixedList .= ', ';
				}

				$prefixedList .= $prefix . trim( $object );
			}

			$query = $preamble . ' ' . $prefixedList . ' ' . $postamble;
		}

		return $query;
	}
function prefixQuery( $regex, $query, $prefix = NULL ) {
		if( !isset( $prefix ) ) {
			return $query;
		}

		if( preg_match( $regex, $query, $match ) ) {
			$preamble = $match[1];
			$postamble = $match[5];
			$objectList = explode( ',', $match[3] );
			// $prefix = $prefix . '_';

			$prefixedList = '';

			foreach( $objectList as $object ) {
				if( $prefixedList !== '' ) {
					$prefixedList .= ', ';
				}

				$prefixedList .= $prefix . trim( $object );
			}

			$query = $preamble . ' ' . $prefixedList . ' ' . $postamble;
		}

		return $query;
	}
function prefixQuery ( $ regex , $ query , $ prefix = NULL ) { if ( ! isset ( $ prefix ) ) { return $ query ; } if ( preg_match ( $ regex , $ query , $ match ) ) { $ preamble = $ match [ 1 ] ; $ postamble = $ match [ 5 ] ; $ objectList = explode ( ',' , $ match [ 3 ] ) ; // $prefix = $prefix . '_'; $ prefixedList = '' ; foreach ( $ objectList as $ object ) { if ( $ prefixedList !== '' ) { $ prefixedList .= ', ' ; } $ prefixedList .= $ prefix . trim ( $ object ) ; } $ query = $ preamble . ' ' . $ prefixedList . ' ' . $ postamble ; } return $ query ; }
Rebuilds the query with the prefix attached to any objects

@param string $regex Regex used to add prefix
@param string $query SQL query string
@param string $prefix Prefix to be appended to tables, indices, etc.
@return string Prefixed SQL query string.
Rebuilds the query with the prefix attached to any objects