Coding with SPIP 2.1
SPIP 2.1 Technical Documentation

> > > > sql_fetsel

sql_fetsel

The sql_fetsel function returns the first row of results for a selection. It accepts the same parameters as the sql_select() function and is a short-cut for the combined call of sql_select() and sql_fetch().

Its parameters are:

  1. $select,
  2. $from,
  3. $where,
  4. $groupby,
  5. $orderby,
  6. $limit,
  7. $having,
  8. $serveur,
  9. $option.

It is used as shown below:

  1. $r = sql_fetsel('colonne', 'table');
  2. // $r['colonne']

Download

Example

Select the "id_trad" and "id_rubrique" columns of a given article:

  1. $row = sql_fetsel("id_trad, id_rubrique", "spip_articles", "id_article=$id_article");
  2. // $row['id_trad'] and $row['id_rubrique']

Download

Select all the columns for a given news item:

  1. $row = sql_fetsel("*", "spip_breves", "id_breve=$id_breve");
  • Author :
  • Published :
  • Updated : 02/06/10
  • Translations : English, français