public function get_models() { //open connection to MySql parent::open_connection(); //initialize arrays $ids = array(); //array for ids $list = array(); //array for objects //query $query = "select mod_id from models where mod_id_make = ?"; //prepare command $command = parent::$connection->prepare($query); //bind params $command->bind_param('i', $this->id); //execute command $command->execute(); //link results $command->bind_result($id); //fill ids array while ($command->fetch()) { array_push($ids, $id); } //close command mysqli_stmt_close($command); //close connection parent::close_connection(); //fill object array for ($i = 0; $i < count($ids); $i++) { array_push($list, new Model($ids[$i])); } //return array return $list; }
function __construct() { if (func_num_args() == 0) { $this->id = ''; $this->name = ''; $this->description = ''; $this->dosification = ''; $this->peridiocity = ""; } if (func_num_args() == 1) { $args = func_get_args(); $id = $args[0]; parent::open_connection(); $query = "select schedule_id, schedule_name, schedule_note from Activities_Schedule where schedule_id = ?"; $command = parent::$connection->prepare($query); $command->bind_param('s', $id); $command->execute(); $command->bind_result($this->id, $this->name, $this->description); $found = $command->fetch(); mysqli_stmt_close($command); parent::close_connection(); if (!$found) { throw new RecordNotFoundException(); } } }
function get_teams() { //open connection to Mysql parent::open_connection(); //initialize array_sum $ids = array(); //array for ids $list = array(); //array for objects //query $query = "select team_id from teams where team_id_div = ?"; //prepare command $command = parent::$connection->prepare($query); //link parameters $command->bind_param('s', $this->id); //execute command $command->execute(); //link results $command->bind_result($id); //fill ids array while ($command->fetch()) { array_push($ids, $id); } //close command mysqli_stmt_close($command); //close connection parent::close_connection(); //fill object array for ($i = 0; $i < count($ids); $i++) { array_push($list, new Team($ids[$i])); } //return array return $list; }
public static function get_tutors() { //open connection to MySql parent::open_connection(); //initialize arrays $ids = array(); //array for ids $list = array(); //array for objects //query $query = "select person_id from Persons_Person"; //prepare command $command = parent::$connection->prepare($query); //execute command $command->execute(); //link results $command->bind_result($id); //fill ids array while ($command->fetch()) { array_push($ids, $id); } //close command mysqli_stmt_close($command); //close connection parent::close_connection(); //fill object array for ($i = 0; $i < count($ids); $i++) { array_push($list, new Person($ids[$i])); } //return array return $list; }
public function get_childs() { parent::open_connection(); $ids = array(); $list = array(); $query = "select child_id from Therapies_Therapy_Child where therapy_id = ?"; $command = parent::$connection->prepare($query); $command->bind_param('s', $this->id); $command->execute(); $command->bind_result($id); while ($command->fetch()) { array_push($ids, $id); } mysqli_stmt_close($command); parent::close_connection(); for ($i = 0; $i < count($ids); $i++) { array_push($list, new Child($ids[$i])); } return $list; }
public function get_activities() { parent::open_connection(); $ids = array(); $list = array(); $query = "select schedule_id from Activities_Schedule_Days where schedule_id = ?"; $command = parent::$connection->prepare($query); $command->bind_param('i', $this->id); $command->execute(); $command->bind_result($id); while ($command->fetch()) { array_push($ids, $id); } mysqli_stmt_close($command); parent::close_connection(); for ($i = 0; $i < count($ids); $i++) { array_push($list, new Activity($ids[$i])); } return $list; }
function __construct() { //if no arguments received, create empty object if (func_num_args() == 0) { $this->id = 0; $this->name = ''; $this->number = ''; $this->image = ''; $this->pos_id = ''; } //if one argument received create object with data if (func_num_args() == 1) { //receive arguments into an array $args = func_get_args(); //id $id = $args[0]; //open connection to Mysql parent::open_connection(); //query $query = "select player_id, player_name, player_number,player_image, player_pos_id from players where player_id = ?"; //prepare command $command = parent::$connection->prepare($query); //link parameters $command->bind_param('i', $id); //execute command $command->execute(); //link results to class attributes $command->bind_result($this->id, $this->name, $this->number, $this->image, $this->pos_id); //fetch data $found = $command->fetch(); //close command mysqli_stmt_close($command); //close connection parent::close_connection(); //if not found throw exception if (!$found) { throw new RecordNotFoundException(); } } }
function __construct() { //if no arguments received, create empty object if (func_num_args() == 0) { $this->id = ''; $this->name = ''; $this->password = ''; } //if two argument received create object with data if (func_num_args() == 2) { //receive arguments into an array $args = func_get_args(); //get arguments $id = $args[0]; $password = $args[1]; //open connection to MySql parent::open_connection(); //query $query = "select usr_id, usr_name from users\n\t\t\t\t\t\t\t\t\twhere usr_id = ? and usr_password = sha1(?);"; //prepare command $command = parent::$connection->prepare($query); //link parameters $command->bind_param('ss', $id, $password); //execute command $command->execute(); //link results to class attributes $command->bind_result($this->id, $this->name); //fetch data $found = $command->fetch(); //close command mysqli_stmt_close($command); //close connection parent::close_connection(); //if not found throw exception if (!$found) { throw new RecordNotFoundException(); } } }
function __construct() { if (func_num_args() == 0) { $this->id = ''; $this->name = ''; } if (func_num_args() == 1) { $args = func_get_args(); $id = $args[0]; parent::open_connection(); $query = "select day_id, day_name from Activities_Days where day_id = ?"; $command = parent::$connection->prepare($query); $command->bind_param('i', $id); $command->execute(); $command->bind_result($this->id, $this->name); $found = $command->fetch(); mysqli_stmt_close($command); parent::close_connection(); if (!$found) { throw new RecordNotFoundException(); } } }
public function get_dosification() { parent::open_connection(); $query = "select dosification from Medicines_Medicine_Child where medicine_id = ?"; $command = parent::$connection->prepare($query); $command->bind_param('s', $this->id); $command->execute(); $command->bind_result($id); $command->fetch(); mysqli_stmt_close($command); parent::close_connection(); return $id; }
public function get_transporter() { parent::open_connection(); $query = "select child_transporter_id from Persons_Child where child_tutor_id = ?"; $command = parent::$connection->prepare($query); $command->bind_param('s', $this->id); $command->execute(); $command->bind_result($id); $command->fetch(); mysqli_stmt_close($command); parent::close_connection(); return $id; }
function get_car_count($min_year, $max_year, $min_price, $max_price) { //open connection to MySql parent::open_connection(); //query $query = 'select count(*) from cars where car_id_model = ?'; if ($min_year != null) { $query .= ' and car_year >= ' . $min_year; } if ($max_year != null) { $query .= ' and car_year <= ' . $max_year; } if ($min_price != null) { $query .= ' and car_price >= ' . $min_price; } if ($max_price != null) { $query .= ' and car_price <= ' . $max_price; } //prepare command $command = parent::$connection->prepare($query); //parameters $command->bind_param('s', $this->id); //execute command $command->execute(); //link results $command->bind_result($count); //read count $command->fetch(); //close command mysqli_stmt_close($command); //close connection parent::close_connection(); //return count return $count; }