[pmwiki-users] Interacting with MySQL

Ben Stallings ben at interdependentweb.com
Tue Jan 15 09:18:06 CST 2008

Rick Cook wrote:
> Actually, the table does have an auto-incrementing integer key field. It also 
> has another field that I am requiring to be a unique email address for each 
> row of the table. I am actually trying to use the SelectQuery to pick out the 
> appropriate integer key field if there is a record that already has the email 
> address entered on the beginning page.

Ah, I see.  It sounds like an (:update select:) might meet your needs as 
well as or better than a SelectQuery... it would certainly take up less 
space on your pages!  Just make sure to put it in a method=get form:

(:input form method=get action=FormPage:)
Edit an existing record:
(:update select ContactID from=TableName label=Email null="Create a new 
(:input submit:)
(:input end:)

> Any suggestions about how to "not specify" the key value for the case when the 
> key value doesn't exist and also specify it when it does? The (`ContactID`)

Sure, that's what the null parameter in the update tag above should do 
-- when the null row is selected, no value is submitted for the 
ContactID.  To do the same thing with SelectQuery, just put a link 
before or after the list saying,

Don't see the email address you're looking for?  [[Create a new record 
-> FormPage]]

By "specify," I mean that there's a ?ContactID=XXX in the URL when you 
go to the page.  So the links generated by SelectQuery specify the 
ContactID, and pretty much any other link you care to create will not 
specify it.

> If I could figure out how to make DataQuery provide the desired functionality, 
> DataQuery would be fine with me.

Now that I know what you're doing, DataQuery is not a good fit.  If you 
were using the unique field as the primary key, DataQuery would be 
perfect, but you can't really do that with email addresses... you'd have 
to either have a calculated field that gets rid of their dots, or use a 
search form to find the records that match a given address.  It sounds 
like you're better off sticking with UpdateForm on this one.

Hope this helps!  --Ben S.

More information about the pmwiki-users mailing list