> Totally wrong ! It's always better to have maximum work done by MySQL
So does that mean that this:
> $countUser = count($arrayUser);
> for($i = 0; $i < $countUser; $i++){
> $sql = "SELECT email FROM table WHERE id = '" . $arrayUser[$i] .
> "' ";
> }
... is faster than this:
> "SELECT e
Dave G wrote:
Is this method faster than just using IN and implode()?
Thanks to all who replied. I believe I have found what I'm looking for
in using the implode() command.
My assumption is that it was faster and more efficient to try and do as
much processing on the PHP side and make as few
> Is this method faster than just using IN and implode()?
Thanks to all who replied. I believe I have found what I'm looking for
in using the implode() command.
My assumption is that it was faster and more efficient to try and do as
much processing on the PHP side and make as few queries to the d
[snip]
> $arrayUser[1] = 'bob';
> $arrayUser[2] = 'cindy';
> $arrayUser[1] = 'mark';
> $countUser = count($arrayUser);
> for($i = 0; $i < $countUser; $i++){
> $sql = "SELECT email FROM table WHERE id = '" . $arrayUser[$i] ."' ";
> }
Is this method faster than just using IN and implode()?
ie, "WHER
> $arrayUser[1] = 'bob';
> $arrayUser[2] = 'cindy';
> $arrayUser[1] = 'mark';
> $countUser = count($arrayUser);
> for($i = 0; $i < $countUser; $i++){
> $sql = "SELECT email FROM table WHERE id = '" . $arrayUser[$i] ."' ";
> }
Is this method faster than just using IN and implode()?
ie, "WHERE id IN
"SELECT email FROM table WHERE id IN ('" . implode("','",$array) . "')";
And don't forget to check if $array really contains only numeric values.
Dave G wrote:
PHP Gurus,
What I'm trying to do must be both common and simple, but I'm
not asking the question right because I can't find the
[snip]
Well, "SELECT email FROM table WHERE id = " . $array . ")";
[/snip]
$arrayUser[1] = 'bob';
$arrayUser[2] = 'cindy';
$arrayUser[1] = 'mark';
$countUser = count($arrayUser);
for($i = 0; $i < $countUser; $i++){
$sql = "SELECT email FROM table WHERE id = '" . $arrayUser[$i] .
"
You can do something like
$str = "'".implode("', '", $arr)."'";
$query = "SELECT * FROM table WHERE id IN ($str)";
Hope this helps,
--
Cordialement,
---
Sophie Mattoug
Développement web dynamique
[EMAIL PROTECTED]
---
Dave G wrote:
PHP Gurus,
What
PHP Gurus,
What I'm trying to do must be both common and simple, but I'm
not asking the question right because I can't find the answers in Google
or the online PHP manual using the search words like array, find, PHP,
MySQL, etc...
I have an array, and I want to select the fields in
9 matches
Mail list logo