Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Retrieving mysql columns by name

From: didier:jacquemart:libertysurf at: 8-Apr-2002 23:08

Thank you for answering my question. Here's another one. --------------------------------------------- I wrote this program : ;; this is the list of columns in my Mysql request zlistechamps: copy [ "livnum" "livtit" "livaut" "livcat" "livdif" "autnum" autabr "autcom" ] getcol: func [ prow 'pnom ] ; prow is the row i get from mysql request ; pnom is the name of the field i want to retrieve [ use [ xind ] [ xind: index? find zlistechamps pnom pick prow xind ] ] I then get my values by : print getcol row "livnum" print getcol row "livtit" print getcol row "autcom" which is equivalent to print row/1 print row/2 print row/8 This way seems to me much more easy and self-explaining than using order numbers. It has the advantage to be request independent. Last problem to solve : How can i automatically create the list of fields in zlistechamps; can i retrieve the columns names from mysql, in a manner like show columns from table . The difference is that the sql request is not upon a table but is a join request. Further, I think the ultimate goal would be object oriented programming, something that could look like this : rq: open_request("select .....") rq/next x: rq/fields "livnum" ... It's just an idea from a newbie in Rebol (i don't even know if the syntax is correct); perhaps does this already exist ? Thank you.