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
MateuszS
post
Post #2





Grupa: Zarejestrowani
Postów: 1 429
Pomógł: 195
Dołączył: 6.10.2008
Skąd: Kraków/Tomaszów Lubelski

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


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