PHP Classes


Recommend this page to a friend!

      PDO Multi Connection Class  >  All threads  >  http://www.  >  (Un) Subscribe thread alerts  
Summary:Package rating comment
Date:2011-02-28 14:16:51
Update:2012-09-03 14:19:17

RicardoSaracino rated this package as follows:

Utility: Sufficient
Consistency: Sufficient

  1. http://www.   Reply   Report abuse  
Picture of RicardoSaracino RicardoSaracino - 2011-02-28 14:16:51 ...

User this

return $con->rowCount();

Instead of this

$count = 0;

foreach($rows as $row){

$count++; //Not is the best way but works!

return $count;

  2. Re: http://www.   Reply   Report abuse  
Picture of Evert Ulises German Soto 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. ...

  3. Re: http://www.   Reply   Report abuse  
Picture of Marco Rossi Marco Rossi - 2012-09-03 14:19:17 - In reply to message 2 from Evert Ulises German Soto
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);

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!!