Jump to content

Help with code

Go to solution Solved by Barand,

Recommended Posts



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:

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?

Link to comment
Share on other sites

  • Solution
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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.