[PHP] Problema nel ricavare una stringa
Ciao a tutti, sto creando una funzione "query" dove questa si suddivide (sino ad ora) in 4 parti in base al testo che contiene... queste sono le strutture:
Citazione:
# Struttura 1: SELECT x FROM y
# Struttura 2: SELECT x FROM y WHERE h = 'i'
# Struttura 3: SELECT x FROM y WHERE h = 'i' ORDER BY f
# Struttura 4: SELECT x FROM y WHERE h = 'i' ORDER BY f LIMIT a,b
Però, richiamandola, con la prima funzione ossia query("SELECT ciccio FROM utenti"); quest'ultima non da nessun output... come mai? Rimane tutto bianco!
Ecco qui il metodo che sto usando (ho scritto solo le prime due)...
Codice PHP:
if(preg_match("/SELECT [^A-Za-z] FROM [^A-Za-z]/",$query)) { return "tipo 1"; }
else if(preg_match("/SELECT [^A-Za-z] FROM [^A-Za-z] WHERE [^A-Za-z] = '[^0-9A-Za-z]'/",$query)) { return "tipo 2"; }
Poi, una volta ricavato il tipo di query, mi servirebbe un metodo per ricavare tutte le impostazioni ad esempio il select sarà $select, il from $from, $where sarà 1 dove vi è h e 2 dove vi è i ... spero di essermi spiegato! =)
Grazie mille. Ciao Davide! :wink: