[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ic] Re: select widget with lookup_select and sql


On 3/21/07, Aaron Berg <suppressed> wrote:
> When editing an image I'd like to have a list of rooms in a drop down
> based on rooms related to the same listing as the image.  I've tried
> putting a query in the extended.lookup_query box in the admin UI (it's
> labeled 'SQL for options').  The query looks like this:
>
> SELECT room_id, room_name FROM listing_rooms WHERE listing_id = [cgi item_id]


I must be on the wrong track for solving this.  Does anyone have any
suggestions on a different direction or a better way to accomplish
this?


This is now solved with some help from Mike Heins.

I had been trying to set the query using meta data and had also tried
something like:

[table-editor
	widget.room_id=select
	lookup_query.room_id="SELECT room_id, room_name
			    FROM listing_rooms
			    WHERE listing_id = [scratch listing_item_id]
				"
	no_top=1
]

This method was incorrectly escaping the query and passing it
literally to MySQL.

Mike gave me this solution:

[table-editor
	widget.room_id=select
	lookup_query.room_id=`
				$Scratch->{listing_item_id} =~ s/\D+//g;
				return qq{
			    SELECT room_id, room_name
			    FROM listing_rooms
			    WHERE listing_id = $Scratch->{listing_item_id}
				};
			`
	no_top=1
]

With the query correctly escaped it works much better. :)
_______________________________________________
interchange-users mailing list
suppressed
http://www.icdevgroup.org/mailman/listinfo/interchange-users


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.