Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Wywołanie fukcji z klasy $klasa->funkcja1('value')->funkcja2('value')
gothye
post
Post #1





Grupa: Zarejestrowani
Postów: 702
Pomógł: 65
Dołączył: 16.03.2009

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


Witam

chce przepisać swoją klasę do obsługi SQL w sposób jaki jest wykorzystywane w Zen

lecz niewiem w jaki sposób zadeklarować dane w klasie abym mógł wykonywać w ten sposób obsługę :

  1.  $users = $sql->select('COUNT(*)')->where('user = 1')->order('ASC');

   


Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
gothye
post
Post #2





Grupa: Zarejestrowani
Postów: 702
Pomógł: 65
Dołączył: 16.03.2009

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


czy o to chodziło ?

  1. class test
  2. {
  3. var $query = array();
  4.  
  5. function __construct()
  6. {
  7.  
  8. }
  9.  
  10. function __set($name,$value)
  11. {
  12. $this->name = $value ;
  13. }
  14.  
  15. function __get($name)
  16. {
  17. return $this->name ;
  18. }
  19.  
  20. public function select($select)
  21. {
  22. $this->query['SELECT'] = $select ;
  23. }
  24.  
  25. public function from($table)
  26. {
  27. $this->query['FROM'] = $table ;
  28. }
  29.  
  30. function where($where)
  31. {
  32. $this->query['WHERE'] = $where ;
  33. }
  34.  
  35. function order($type)
  36. {
  37.  
  38. }
  39.  
  40. function __destruct()
  41. {
  42.  
  43. }
  44.  
  45. }
  46.  
  47. $test = new test() ;
  48. $test->select('COUNT(*)')->from('users')->where('User=2');



Wynik : Fatal error: Call to a member function from() on a non-object (IMG:style_emoticons/default/sad.gif)

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: 11.06.2026 - 09:13