claudiaraquelcp Posted June 15, 2021 Share Posted June 15, 2021 Hi, if i have a class named “employeer” with some attributes: id, name, age, job, salary and admission_date. This class can have a method that calls database with MYSQL? This is the code: <?php class employeer { public id; public name; public age; public job; public salary; public admission_date; public id_employee; public description; public value; public status; public delivery_date; public function getId() { return $this->id; } public function setId($id) { $this->id = $id; } public function getName() { return $this->name; } public function setName($name) { $this->name = $name; } public function getEmployersJobs() { $conn = mysqli_connect("localhost", "my_user", "my_password", "staff"); $results = array(); $dob_array = mysqli_query($conn, "SELECT job FROM employees"); while($row = mysqli_fetch_assoc($dob_array)){ $results[] = $row; } return $results; } } ?> Does the method getEmployersJobs() is well implemented? Quote Link to comment https://forums.phpfreaks.com/topic/312911-help-with-code/ Share on other sites More sharing options...
Solution Barand Posted June 15, 2021 Solution Share Posted June 15, 2021 50 minutes ago, claudiaraquelcp said: Does the method getEmployersJobs() is well implemented? If you want to return all jobs for all employees each time it is called, the yes. If you just want jobs for that employee, then no. Please use code tags button "<>" when posting code and use indentations to render it more readable Quote Link to comment https://forums.phpfreaks.com/topic/312911-help-with-code/#findComment-1587233 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.