[Zope] ZSQL Method Question

Cliff Ford Cliff.Ford at ed.ac.uk
Tue Jul 18 04:01:03 EDT 2006

This is how it works for MySQL:

insert into org (org_name, org_phone) values ('x', 'y')
<dtml-var sql_delimiter>
select LAST_INSERT_ID() as org_id

You have to have the select LAST_INSERT_ID call in the same query as the 
insert, and you have to have the sql_delimiter.

I assume you know that the x and y values should be <sql-var ...> types.


Benjamin Menking wrote:
> New to python/Zope, old-timer on PHP....
> I'm using MySQL and a ZSQL method to insert data into the database.  ex:
>    insert into org (org_name, org_phone) values ('x', 'y')
> What I'm trying to figure out is that org_id (also part of the org 
> table, but not specified in the sql statement) is an auto_increment 
> primary key field and in PHP I can use mysql_insert_id() to find out 
> what org_id was set to after the mysql_query() call.
> Is there a way to retrieve that value with ZSQL method, or must I use 
> some other mechanism?
> Thanks!
> ------------------------------------------------------------------------
> _______________________________________________
> Zope maillist  -  Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )

More information about the Zope mailing list