You are here: Re: retrieving multiple rows advice « PHP Programming Language « IT news, forums, messages
Re: retrieving multiple rows advice

Posted by Bob Stearns on 11/22/05 09:00

julian_m wrote:
> let's say I've an array of articles's id
>
> $arr_art_id=(1, 551, 2015, 6 .......n )
>
> what option is better (1 or 2), in order to achieve better performance?
>
> (pseudo code)
> 1)
> for i=0 to array count{
> select * from articles where articles.id=$arr_art_id[i]
> mysqlquery($sql)
> //do whatever i have to do
> }
>
>
> 2)
>
> $or ='';
> for i=0 to array count{
> $sql.= $or . 'articles.id='. $arr_art_id[i];
> $or ='or';
> }
>
> $sql = 'select * from articles where' .$sql
>
>
> //do whatever i have to do
>
> tia
>
> regards - julian maisano
>
Better than either:

$sql = 'select * from articles where articles.id in ($arr_art_id)';
mysqlquery($sql);
//do whatever i have to do

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация