sql-statements in DTML-Methods....
Hi. This is one of the first times I'm working with Zope and databases. Until now - if I wanted to work with a databse, i always created a Z SQL method that I called from my DTML-method via <dtml-call "add_item(param1 = ..., param2 = ..., param3 = ..., ..."> (for example) or <dtml-in get_items> ... </dtml-in> (for example) In the Z SQL method 'add_item' or 'get_items', my SQL statement are defined. My question is now: Do I have to define one Z SQL Method for every SQL statement I want to perform on my database or is it possible to define SQL-statements and database requests in my DTML-method? Am I missing something? Any idea? Thanks a lot. Regards, Marc mailto:lutschi72@gmx.net
Zope differs from PHP and ASP systems in this regard. I don't think anyone using Zope that I've seen inlines SQL inside DTML. The separation of SQL and presentation via DTML is intentional. Though it's not always as expedient, the intent of the separation is to provide you with layers of abstraction that make it easier to maintain and modify your code later. That said, I imagine you could do it by constructing a string inside DTML that has the sql query and passing it in to a dummy SQL method that performs the query and returns the results. Marc LUDWIG wrote:
My question is now:
Do I have to define one Z SQL Method for every SQL statement I want to perform on my database or is it possible to define SQL-statements and database requests in my DTML-method?
Am I missing something? Any idea? Thanks a lot.
For the most part all a ZSQL method does is used some specialized DTML syntax to contruct a string that is your SQL query. You can create a ZQL method, say "GenericSQL", that has 1 parameter, let's call it "SQLStatement", whose sole DTML statement is "<dtml-var SQLStatement>". To use it you would do this: <dtml-in "GeneicSQL(SQLStatement='select * from the_table where the_var = \'var_value\'')> ... </dtml-in> You can replace the literal string with a string variable like from a filed on a form where you entered you SQL statement. I use this method extensively. Jim Sanford ----- Original Message ----- From: "Marc LUDWIG" <lutschi72@gmx.net> To: <zope@zope.org>; <zope-dev@zope.org> Sent: Sunday, June 18, 2000 3:08 PM Subject: [Zope] sql-statements in DTML-Methods.... Hi. This is one of the first times I'm working with Zope and databases. Until now - if I wanted to work with a databse, i always created a Z SQL method that I called from my DTML-method via <dtml-call "add_item(param1 = ..., param2 = ..., param3 = ..., ..."> (for example) or <dtml-in get_items> ... </dtml-in> (for example) In the Z SQL method 'add_item' or 'get_items', my SQL statement are defined. My question is now: Do I have to define one Z SQL Method for every SQL statement I want to perform on my database or is it possible to define SQL-statements and database requests in my DTML-method? Am I missing something? Any idea? Thanks a lot. Regards, Marc mailto:lutschi72@gmx.net _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Chris McDonough -
Jim Sanford -
Marc LUDWIG