Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class EmployeeService {
- var $username = "test";
- var $password = "test";
- var $server = "localhost";
- var $port = "3306";
- var $databasename = "testdrive_db";
- var $tablename = "employees";
- var $connection;
- public function __construct() {
- $this->connection = mysqli_connect(
- $this->server,
- $this->username,
- $this->password,
- $this->databasename,
- $this->port
- );
- $this->throwExceptionOnError($this->connection);
- }
- public function getEmployees() {
- $stmt = mysqli_prepare($this->connection,
- "SELECT
- employees.id,
- employees.firstname,
- employees.lastname,
- employees.title,
- employees.departmentid,
- employees.officephone,
- employees.cellphone,
- employees.email,
- employees.street,
- employees.city,
- employees.state,
- employees.zipcode,
- employees.office,
- employees.photofile
- FROM employees");
- $this->throwExceptionOnError();
- mysqli_stmt_execute($stmt);
- $this->throwExceptionOnError();
- $rows = array();
- mysqli_stmt_bind_result($stmt, $row->id, $row->firstname,
- $row->lastname, $row->title, $row->departmentid,
- $row->officephone, $row->cellphone, $row->email,
- $row->street, $row->city, $row->state,
- $row->zipcode, $row->office, $row->photofile);
- while (mysqli_stmt_fetch($stmt)) {
- $rows[] = $row;
- $row = new stdClass();
- mysqli_stmt_bind_result($stmt, $row->id, $row->firstname,
- $row->lastname, $row->title, $row->departmentid,
- $row->officephone, $row->cellphone, $row->email,
- $row->street, $row->city, $row->state,
- $row->zipcode, $row->office, $row->photofile);
- }
- mysqli_stmt_free_result($stmt);
- mysqli_close($this->connection);
- return $rows;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement