Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> return a echo, roznica ???
xblant
post 4.06.2006, 16:04:20
Post #1





Grupa: Zarejestrowani
Postów: 76
Pomógł: 0
Dołączył: 31.01.2006

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


P.S. teksty roznia sie 56 linia.
Gdy na pisze tak to mi zawsze wypisze wartosc z bazy:
  1. <?php
  2. class db_vievRec extends db_query
  3. {
  4. var $where;
  5. var $coll;
  6. var $tabName;
  7. var $structFile;
  8. var $tableFile;
  9. var $row;
  10. var $ret;
  11.  
  12. function execute($db)
  13. {
  14.  
  15. $this -> tableFile = dataBasePath.$db -> baseName.'/'.$this -> tabName.table;
  16. $this -> structFile = dataBasePath.$db -> baseName.'/'.$this -> tabName.struct;
  17.  
  18. $fp = fopen($this -> structFile, 'a+');
  19. $coll = unserialize(fread($fp, filesize($this -> structFile)));
  20. fclose($fp);
  21.  
  22. for($i = '0'; $i < count($coll); $i++)
  23. {
  24. if($this -> coll == $coll[$i])
  25. {
  26. $this -> coll = $i;
  27. break;
  28. }
  29. }
  30.  
  31. for($i = '0'; $i < count($coll); $i++)
  32. {
  33. if($this -> where[0] == $coll[$i])
  34. {
  35. $this -> where[0] = $i;
  36. break;
  37. }
  38. }
  39.  
  40. $row = file($this -> tableFile);
  41.  
  42. for($i = '0'; $i < count($row); $i++)
  43. {
  44. $row[$i] = unserialize($row[$i]);
  45. }
  46.  
  47. for($i = '0'; $i < count($row); $i++)
  48. {
  49. if($this -> where[1] == $row[$i][$this -> where[0]])
  50. {
  51. $this -> row = $i;
  52. break;
  53. }
  54. }
  55.  
  56. echo $row[$this -> row][$this -> coll];
  57. }
  58.  
  59. function db_vievRec($tabName, $coll, $where)
  60. {
  61. $this -> tabName = $tabName;
  62. $this -> coll = $coll;
  63. $this -> where = $where;
  64. }
  65. }
  66. ?>

a gdzy tak:
  1. <?php
  2. class db_vievRec extends db_query
  3. {
  4. var $where;
  5. var $coll;
  6. var $tabName;
  7. var $structFile;
  8. var $tableFile;
  9. var $row;
  10. var $ret;
  11.  
  12. function execute($db)
  13. {
  14.  
  15. $this -> tableFile = dataBasePath.$db -> baseName.'/'.$this -> tabName.table;
  16. $this -> structFile = dataBasePath.$db -> baseName.'/'.$this -> tabName.struct;
  17.  
  18. $fp = fopen($this -> structFile, 'a+');
  19. $coll = unserialize(fread($fp, filesize($this -> structFile)));
  20. fclose($fp);
  21.  
  22. for($i = '0'; $i < count($coll); $i++)
  23. {
  24. if($this -> coll == $coll[$i])
  25. {
  26. $this -> coll = $i;
  27. break;
  28. }
  29. }
  30.  
  31. for($i = '0'; $i < count($coll); $i++)
  32. {
  33. if($this -> where[0] == $coll[$i])
  34. {
  35. $this -> where[0] = $i;
  36. break;
  37. }
  38. }
  39.  
  40. $row = file($this -> tableFile);
  41.  
  42. for($i = '0'; $i < count($row); $i++)
  43. {
  44. $row[$i] = unserialize($row[$i]);
  45. }
  46.  
  47. for($i = '0'; $i < count($row); $i++)
  48. {
  49. if($this -> where[1] == $row[$i][$this -> where[0]])
  50. {
  51. $this -> row = $i;
  52. break;
  53. }
  54. }
  55.  
  56. return $row[$this -> row][$this -> coll];
  57. }
  58.  
  59. function db_vievRec($tabName, $coll, $where)
  60. {
  61. $this -> tabName = $tabName;
  62. $this -> coll = $coll;
  63. $this -> where = $where;
  64. }
  65. }
  66. ?>

nic nie zwraca(czy chce przypoisac do zmiennej czy wyswietlic echo nic) jaka moze byc pezyczyna


--------------------
Go to the top of the page
+Quote Post
em1X
post 4.06.2006, 17:16:12
Post #2





Grupa: Zarejestrowani
Postów: 984
Pomógł: 41
Dołączył: 16.03.2002
Skąd: Płock

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


Skoro uzyles return to kod zwroci wynik dopiero, gdy uzyjesz echo $obiekt->execute(...) ?


--------------------
eh, co polska wódka to polska wódka
Go to the top of the page
+Quote Post
xblant
post 5.06.2006, 19:43:26
Post #3





Grupa: Zarejestrowani
Postów: 76
Pomógł: 0
Dołączył: 31.01.2006

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


i tak to odpalam ale czemu nie zwraca bo jak chce przypisac do zmiennej to nie przypisze a jak wyswietlic to ttesh nie dziala


--------------------
Go to the top of the page
+Quote Post
dr_bonzo
post 5.06.2006, 19:50:33
Post #4





Grupa: Przyjaciele php.pl
Postów: 5 724
Pomógł: 259
Dołączył: 13.04.2004
Skąd: N/A

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


daj

var_dump( $row[$this -> row][$this -> coll] );

tuz przed tym returnei lub echo i bedziesz wiedzial czy cos tam w ogole jest do wypisania, zwrocenia.


--------------------
Nie lubię jednorożców.
Go to the top of the page
+Quote Post
xblant
post 5.06.2006, 20:05:39
Post #5





Grupa: Zarejestrowani
Postów: 76
Pomógł: 0
Dołączył: 31.01.2006

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


napewno jest bo jak napisze echo to mi wypiszer to co chce ale ja potrzebuje return zeby zwrocilo to co ma zwrucic zeby mozna bylo przypisac do zmmiennej

--EDIT--

napisalem tak jak pisales i zwrocilo "string(7) "Piotrek"" a wywoluje to tak
  1. <?php
  2. include('db.php');
  3. $db = new db;
  4. $db -> createBase('test');
  5. $db -> conect('test', 'pass');
  6. $db -> query(new db_createTab('test', array('id', 'nazwa')));
  7. $db -> query(new db_insertRec('test', array('1', 'XBlant')));
  8. $db -> query(new db_insertRec('test', array('2', 'Piotrek')));
  9. $db -> query(new db_insertRec('test', array('3', 'Adrian')));
  10. $test = $db -> query(new db_vievRec('test', 'nazwa', array('id', '2')));
  11. echo $test;
  12. echo $db -> getLastError();
  13. ?>

i wyswietla tylko
Kod
string(7) "Piotrek"

a powinno jeszce na koncu wypisac "Piotrek" nie logiczne prawda

Ten post edytował xblant 5.06.2006, 20:10:23


--------------------
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 19.07.2025 - 16:12