[support] Problem with db_update containing a CONCAT condition.
ALLAHBAKASH ALLAHBAKASH
allahbakash2 at gmail.com
Tue Jun 5 03:38:07 UTC 2012
Look Wether You can Translate All Directly. There Are Many Methods.
On 6/5/12, Nicolas Poulain <nico.poulain at gmail.com> wrote:
> Hello,
>
> I have an update query i'd like to translate into a more «7» way but I
> don't know how to write one of the conditions that contains a CONCAT
> statement.
>
> db_query("
> UPDATE {gbb_session}
> SET co_resp = (SELECT co_resp FROM {gbb_gresp_dafor} WHERE
> CONCAT(prenom,' ',nomu) = :formateur)
> WHERE sess_id = :sess_id"
> ", array( ':sess_id' => $form_state['values']['sess_id'],
> ':formateur' => $form_state['values']['formateur']));
>
> Here is what i tried ; it doesn't work ...
>
> $subquery = db_select('gbb_gresp_dafor', 'r')
> ->fields('r', array('co_resp'))
> ->condition('CONCAT(prenom,\' \',nomu)',
> $form_state['values']['formateur'], '=')
> ->execute();
>
> db_update('gbb_session','s')
> ->fields(array('co_resp' => $subquery))
> ->condition('sess_id', $form_state['values']['sess_id'], '=')
> ->execute();
>
> Any help, would be appreciate.
>
> --
> Nicolas poulain
> http://exomatik.net
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
More information about the support
mailing list