本文整理汇总了PHP中Connection::open_connection方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::open_connection方法的具体用法?PHP Connection::open_connection怎么用?PHP Connection::open_connection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection::open_connection方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_models
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;
}
示例2: RecordNotFoundException
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();
}
}
}
示例3: array
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;
}
示例4: get_tutors
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;
}
示例5: get_childs
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;
}
示例6: get_activities
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;
}
示例7: RecordNotFoundException
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();
}
}
}
示例8: 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();
}
}
}
示例9: 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();
}
}
}
示例10: get_dosification
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;
}
示例11: get_transporter
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;
}
示例12: count
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;
}