Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> PDO i num_rows .
nekomata
post
Post #1





Grupa: Zarejestrowani
Postów: 314
Pomógł: 44
Dołączył: 12.11.2010
Skąd: UK

Ostrzeżenie: (0%)
-----


Postanowiłem przenieść się z mysqli n PDO za sugestią z tego tematu i właśnie uaktualniam moje skrypty.Jednak mam takowy problem.. mam taki kodzik
  1. $avatar = $dbc->prepare('SELECT img3030 FROM avatars WHERE nick=? LIMIT 1');
  2. $avatar->execute(array($_GET['user']));
  3. if($avatar->rowCount() > 0){
  4. while($row=$avatar->fetch(PDO::FETCH_ASSOC)){
  5. echo 'znaleziono';
  6. /*header('Content-type: image/png');
  7. $img = imagecreatefromstring($row[$type]);
  8. imagepng($img);*/
  9. }
  10. }
  11. else{
  12. echo 'Nieznaleziono';
  13. /*header('Content-type: image/png');
  14. $image = imagecreatefrompng('../style/img/noavatar.png');
  15. imagepng($image);*/
  16. }
Właśnie z tym rowCount jest problem bo nie działa tak jak powinien.(albo ja go nie używam jak powinienem) , czy jest jakaś alternatywa w PDO która działałaby tak jak mysqli_num_rows?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
gregory90
post
Post #2





Grupa: Zarejestrowani
Postów: 9
Pomógł: 1
Dołączył: 3.10.2009

Ostrzeżenie: (0%)
-----


http://php.net/manual/en/pdostatement.rowcount.php
"If the last SQL statement executed by the associated PDOStatement was a SELECT statement, some databases may return the number of rows returned by that statement. However, this behaviour is not guaranteed for all databases and should not be relied on for portable applications. "
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 7.10.2025 - 11:18