Coding with SPIP 3.0
SPIP3.0 Technical Documentation

> > > > sql_in_select

sql_in_select

The function sql_in_select() returns a sql_in from the result of a sql_select.

It accepts the same arguments as sql_select plus one additional parameter in first place:

  1. $in is the name of the column on which the IN will be applied,
  2. $select,
  3. $from,
  4. $where,
  5. $groupby,
  6. $orderby,
  7. $limit,
  8. $having,
  9. $serveur,
  10. $option.

You can use it like this:

  1. $where = sql_in_select("column", "column", "tables", "id_parent = $id_parent"));
  2. // $where: column IN (3, 5, 7)
  3. if ($res = sql_select('column', 'another_table', $where)) {
  4. // ...
  5. }

Download

Example

Delete every link between an article and the keywords of a given keyword group:

  1. sql_delete("spip_mots_articles", array(
  2. "id_article=" . $id_article,
  3. sql_in_select("id_mot", "id_mot", "spip_mots", "id_groupe = $id_groupe"));

Download