fork download
  1. <?php
  2.  
  3. namespace core {
  4.  
  5. class connect {
  6.  
  7. }
  8.  
  9. abstract class read extends connect{
  10. public static function select($bdName,$tableName,$select,$where){
  11. $connection=connect::connect();
  12. if(isset($where)&&$where!=false){
  13. $whereFlag=true;
  14. }else{
  15. $whereFlag=false;
  16. }
  17. switch($whereFlag):
  18. case false:
  19. $query="SELECT ".$select." FROM ".$bdName.".".$tableName;
  20. break;
  21. case true:
  22. $query="SELECT ".$select." FROM ".$bdName.".".$tableName." WHERE ".$where;
  23. break;
  24. endswitch;
  25. $result=mysqli_query($connection,$query);
  26. return $result;
  27. }
  28. }
  29. }
  30.  
  31.  
  32. namespace core\classes {
  33.  
  34. use core\read;
  35. class users extends read{
  36. protected $bdName,$tableName,$select,$where;
  37. protected function setTable($tableName){
  38. $this->tableName=$tableName;
  39. return $this->tableName;
  40. }
  41. protected function testuser() {
  42. echo "Hello from ".__LINE__."\n";
  43. }
  44. protected function setSelect($select){
  45. $this->select=$select;
  46. return $this->select;
  47. }
  48. protected function setWhere($where){
  49. $this->where=$where;
  50. return $this->$where;
  51. }
  52. public function __construct(){
  53. //конструктор поломал для теста;
  54. }
  55. }
  56.  
  57. class admin extends users{
  58. private $login,$pass;
  59. public function test() {
  60. $this->testuser();
  61. }
  62.  
  63. private function setLogin($login){
  64. $this->login=$login;
  65. return true;
  66. }
  67. private function setPass($pass){
  68. $this->pass=$pass;
  69. return true;
  70. }
  71. private function login(){
  72. // users:: - здесь из доступных наследуемых функций только select из класса readDB
  73. $getLogin=users::select($this->bdName,$this->tableName,$this->select,$this->where);
  74. $hashPass=password_hash($this->pass,PASSWORD_DEFAULT);
  75. }
  76. }
  77.  
  78. $admin=new admin;
  79.  
  80. $admin->test();
  81.  
  82. }
  83.  
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Hello from 42