Subject: | http://www. |
Summary: | Package rating comment |
Messages: | 3 |
Author: | RicardoSaracino |
Date: | 2011-02-28 14:16:51 |
Update: | 2012-09-03 14:19:17 |
|
|
|
RicardoSaracino rated this package as follows:
Utility: | Sufficient |
Consistency: | Sufficient |
|
RicardoSaracino - 2011-02-28 14:16:51
php.net/manual/en/pdostatement.rowc ...
User this
return $con->rowCount();
Instead of this
$count = 0;
foreach($rows as $row){
$count++; //Not is the best way but works!
}
return $count;
Evert Ulises German Soto - 2011-02-28 18:23:13 - In reply to message 1 from RicardoSaracino
PDOStatement::rowCount() returns the number of rows affected by a DELETE, INSERT, or UPDATE statement.
Not works in Select Statement...
For most databases, PDOStatement::rowCount() does not return the number of rows affected by a SELECT statement. Instead, use PDO::query() to issue a SELECT COUNT(*) statement with the same predicates as your intended SELECT statement, then use PDOStatement::fetchColumn() to retrieve the number of rows that will be returned. Your application can then perform the correct action.
php.net/manual/en/pdostatement.rowc ...
Marco Rossi - 2012-09-03 14:19:17 - In reply to message 2 from Evert Ulises German Soto
Hi!!!
How can i make a fetch_object?
normally in mysql i made:
while ($query_res = mysql_fetch_object($queryMade))
{
$arrayValues[] = $query_res;
}
$jsonValues = json_encode($arrayValues);
But if i take the object extracted from the pdo query:
$rows = $db_pdo->query_secure($query, $params, true, false);
if($rows!=false){
print_r($rows);
}
it prints me an architecture like this:
Array ( [0] => Array ( [user_id] => 41 [0] => 41 [user_values] => 14 [1] => 14 [ID_user_to] => 8 [2] => 8 ) )
it replicates all the fields and so i can't create a correct json.
How can i fix this problem?
thank you!!
|