Page 1 of 1

How can I use a CONCAT MySQL function in a valuelist ?

PostPosted: Thu Dec 10, 2009 5:59 am
by Jean
Hi Steve,

When I use a CONCAT or a CONCAT_WS function in my valuelist :
Code: Select all
[sous_type_liste]
__sql__ = "SELECT sous_type_contacts.sous_type_contact_id, CONCAT_WS( "__", sous_type_contacts.sous_type_contact_name, type_contacts.type_contact_name ) AS sous_type_contact_name, type_contacts.type_contact_id
FROM sous_type_contacts
NATURAL LEFT JOIN type_contacts
ORDER BY sous_type_contacts.sous_type_contact_name"


I have this error

Error parsing /var/www/listepc/tables/envois/valuelists.ini on line 2 in /var/www/listepc/xataface-1.1.2/Dataface/ConfigTool.php on line 331

Notice: Valuelist query 'SELECT sous_type_contacts.sous_type_contact_id, CONCAT_WS( ' failed. On line 1138 of file /var/www/listepc/xataface-1.1.2/Dataface/Table.php in function printstacktrace()


Is there a solution ? It is made to have a dynamic second select box.

Jean

PostPosted: Fri Dec 11, 2009 7:19 am
by Jean
Hello,
Eventually, I found something else to avoid it.
Thank you
Jean

PostPosted: Fri Dec 11, 2009 7:46 am
by Jean
I added a page about ths dynamic select boxes from the posts of Steve in the forum. If someone wants to add something :
http://xataface.com/wiki/index.php?-action=view&-table=wiki&page_id=%3D90&-cursor=0&-skip=0&-limit=30&-mode=list
Jean

PostPosted: Fri Dec 11, 2009 10:15 am
by shannah
In response to the CONCAT_WS problem. It is likely the case that some functions (e.g. CONCAT_WS aren't registered with the parser as available mysql functions). You can add missing functions in the lib/SQL/Parser/Dialect_MySQL.php file, in the 'functions' array.

(Although I believe that concat_ws should already be there).

PostPosted: Fri Dec 11, 2009 10:17 am
by shannah
Oh... here's our problem.
Code: Select all
sql__ = "SELECT sous_type_contacts.sous_type_contact_id, CONCAT_WS( "__",  ....


You're using double quotes inside double quotes. Use single quotes inside your CONCAT_WS function and it should work:

e.g.
CONCAT_WS('__', ...
instead of
CONCAT_WS("__", ...

PostPosted: Fri Dec 11, 2009 10:44 am
by Jean
:oops: