Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][MySQL][PostgreSQL] pg_fetch_field ?
jigsaw
post
Post #1





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 20.01.2007

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


Przerabiam bazę danych MySQL na PostgreSQL, mam następującą funkcję w PHP obsługującą bazę MySQL:

  1. function _mysql_fetch_array($result)
  2. {
  3. $table_result=array();
  4. $r=0;
  5. while($row = mysql_fetch_assoc($result)){
  6. $arr_row=array();
  7. $c=0;
  8. while ($c < mysql_num_fields($result)) {
  9. $col = mysql_fetch_field($result, $c);
  10. $arr_row[$col -> name] = $row[$col -> name];
  11. $c++;
  12. }
  13. $table_result[$r] = $arr_row;
  14. $r++;
  15. }
  16. return $table_result;
  17. }


która musi działać analogicznie na bazie PostgreSQL:

  1. function _pg_fetch_array($result)
  2. {
  3. $table_result=array();
  4. $r=0;
  5. while($row = pg_fetch_assoc($result)){
  6. $arr_row=array();
  7. $c=0;
  8. while ($c < pg_num_fields($result)) {
  9. $col = pg_fetch_field($result, $c);
  10. $arr_row[$col -> name] = $row[$col -> name];
  11. $c++;
  12. }
  13. $table_result[$r] = $arr_row;
  14. $r++;
  15. }
  16. return $table_result;
  17. }


niestety w PHP nie ma funkcji pg_fetch_field. W jaki sposób można rozwiązać jej brak? Funkcja _pg_fetch_array($result) musi zwracać tablicę o identycznej strukturze jak funkcja _mysql_fetch_array($result)
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: 24.08.2025 - 21:08