Rev cgi & mySQL (again)

jbv jbv.silences at club-internet.fr
Fri Jan 2 10:13:58 EST 2009



Bill, Ruslan,

Thanks for your answers.

To answer some of your questions, I only need to read data from mySQL,
and the nested booleans are of the ( ... OR ... OR ...) AND ( ... OR ...) type.

I don't if anyone's interested, but here are examples of my code :

--    example 1 : using mySQL

put quote into q
put "" into b
repeat for each item i in myList1        --    myList1 may contain up to 50 items
    put " OR Col1 = " &q& i &q& " OR Col2 = " &q& i &q after b
end repeat
put "(" into word 1 of b
put " ) " after b

if item x of myList2 is not "0" then
    put "" into a
    get item x of myList2
    repeat for each char k in it        --    may contain up to 10 chars
        if a = "" then
            put " Col3 LIKE " &q& k & "%" &q& " OR Col3 LIKE " &q& "%/" & k & "%" &q into a
        else
            put " OR Col3 LIKE " &q& k & "%" &q& " OR Col3 LIKE " &q& "%/" & k & "%" &q
after a
        end if
     end repeat
    if a is not "" then
        put " AND ( " & a & " ) " after b
    end if
end if

put "SELECT Col10, Col11, Col12, Col13, Col14, Col15 FROM myTable WHERE " & b &" AND Col20
!= " &q&q into myREQUEST
put revDataFromQuery(,,theID,myREQUEST,) into myVar



--    example 2 : using Rev

--    reads table dump
 open file path
 read from file path until EOF
 close file path
 put it into myV0        --    table dump already includes the Col20 != ""  condition from
the above SQL request

put quote into q

put "" into myV
if myList1 is not 0 then
    put "" into c
    repeat for each char k in myList2
        if c = "" then
            put " char 1 of d = " &q& k &q& " or d contains " &q& "/" & k &q into c
        else
            put " or char 1 of d = " &q& k &q& " or d contains " &q& "/" & k &q after c
        end if
    end repeat
    repeat for each line j in myV0
        get item 1 of j
        put item 3 of j into a
        put item 4 of j into d
        repeat for each item i in myList1
            if (it = i or a = i) and (the value of c) then
                put j &cr after myV
                exit repeat
            end if
        end repeat
    end repeat
else
    repeat for each line j in myV0
        get item 1 of j
        put item 3 of j into a
        repeat for each item i in myList1
            if it = i or a = i then
                put j &cr after myV
                exit repeat
            end if
        end repeat
    end repeat
end if




More information about the use-livecode mailing list