Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Odwolanie do funkcji z innej klasy
Wolfie
post
Post #1





Grupa: Zarejestrowani
Postów: 686
Pomógł: 0
Dołączył: 10.11.2008
Skąd: Łódź

Ostrzeżenie: (20%)
X----


Witam,

Mam sobie klase Database w ktorej mam nastepujaca funkcje :

  1. public function query($sql) {
  2. $resultSet = mysql_query($sql, $this->connection);
  3. $result = array();
  4. while($r = mysql_fetch_assoc($resultSet)) {
  5. $result[] = $r;
  6. }
  7. return $result;
  8. }


I teraz w innej klasie ktora oddziela zapytania sql od klasy Database mam oto taka przykladowa funkcje :

  1. function find($id) {
  2. if(!$result = mysql_query("SELECT * FROM $this->tableName WHERE id='$id'")){
  3. throw new Exception('Error finding row');
  4. }
  5. $row = mysql_fetch_assoc($result);
  6. print_r($row);
  7. }


Teraz moje pytanie brzmi , jak odwolac sie w funkcji find() do funkcji query() zeby nie trzeba bylo powtarzac funkcji mysql_query ?

Jak to przerobic ?

Ten post edytował Wolfie 13.08.2009, 21:04:23
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: 26.09.2025 - 12:19