本文整理汇总了PHP中database::get_instance方法的典型用法代码示例。如果您正苦于以下问题:PHP database::get_instance方法的具体用法?PHP database::get_instance怎么用?PHP database::get_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类database
的用法示例。
在下文中一共展示了database::get_instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post_profile
public function post_profile($table, $col_name, $type)
{
$this->object = database::get_instance();
$users = DB::table('users_login')->orderBy('id', 'desc')->first();
$stu_id = $users->user_session;
$id = $this->object->view($table, "where_pluck", $col_name, '=', $stu_id, 'id');
$profile_image = $this->object->view($table, "where_pluck", 'id', '=', $id, 'profile_image');
Session::put('table', $table);
if (Auth::attempt(array('password' => Input::get('old_pass')))) {
if (Input::get('new_pass') == Input::get('pass_confirm')) {
$this->add_file = $this->object->upload_file('profile_images', $table, 'upload', 'profile_image', "update", 'id', $id, $profile_image);
$val = array('password' => Hash::make(Input::get('new_pass')));
$this->object->update($table, 'id', $id, $val);
} else {
$return = Redirect::to('profile=' . $type)->with('exists', 'Please Enter Correct new password');
}
} else {
$return = Redirect::to('profile=' . $type)->with('exists', 'Please Enter Correct Old password');
}
if ($this->add_file) {
$return = Redirect::to('profile=' . $type)->with('success', 'You successfully Update Your Profile.');
} else {
$return = Redirect::to('profile=' . $type)->with('exists', 'Please Select a file');
}
return $return;
}
示例2: post_make_notify
public function post_make_notify($type)
{
$object = database::get_instance();
$data = ['msg' => Input::get('des')];
$table = Input::get('choose');
$col = '';
$count = 0;
Session::put("key", $type);
$col = 'mail';
$count = DB::table('register_course_section')->where('course_id', '=', Input::get('courses'))->count('student_id');
$array = array();
for ($i = 0; $i < $count; $i++) {
if ($object->view("{$table}", 'where_pluck', 'id', '=', $i + 1, $col)) {
$array[$i] = $object->view("{$table}", 'where_pluck', 'id', '=', $i + 1, $col);
}
}
Mail::queueOn('mail', 'emails.mailer', $data, function ($message) use($array) {
$file = Input::file('upload');
$destinationPath = "/wamp/www/GradeSystem/public/assets/Notify_files";
$filename = str_random(6) . '_' . $file->getClientOriginalName();
$uploadSuccess = $file->move($destinationPath, $filename);
$subject = Input::get('subject');
$description = Input::get('des');
if (Session::get("key") == "assignment") {
$val = array("course_id" => Input::get('courses'), "teacher_id" => Input::get('teacher_id'), "grade" => Input::get('grade'), "deadline" => Input::get('deadline'), "assignment" => $filename, "assignment_name" => $subject, "description" => $description);
$o = database::get_instance();
$o->add("prof_teacher_assignment", $val);
}
$message->to($array)->subject($subject);
$message->attach("{$destinationPath}/{$filename}");
});
return Redirect::to('make_teacher_notify=' . $type)->with('success', 'You Successfully Notify all Your ' . "{$table}");
}
示例3: save
public function save()
{
$db = database::get_instance();
if (count($this->changed_entries) > 0) {
$tmp = array();
$bool = false;
foreach ($this->changed_entries as $name) {
if ($name == "table") {
continue;
}
if ($name == "{$this->table}_id") {
$bool = true;
}
$value = $this->entries[$name] === 'NULL' || $this->entries[$name] === null ? "NULL" : "'" . $db->escape($this->entries[$name]) . "'";
$tmp[] = "`{$name}` = {$value}";
}
if ($bool == false && isset($this->entries["{$this->table}_id"])) {
$tmp[] = "`{$this->table}_id` = '" . $db->escape($this->entries["{$this->table}_id"]) . "'";
}
$sql = "INSERT INTO `{$this->table}` SET " . implode(",", $tmp) . " ON DUPLICATE\n\t\t\t\t\t\t\tKEY UPDATE " . implode(",", $tmp) . ";";
debug::add_info("(" . __FILE__ . ")<b>" . __CLASS__ . "</b>::" . __FUNCTION__ . "(): \$sql:<br /><pre>{$sql}</pre>");
$result = $db->query($sql);
if (!isset($this->entries["{$this->table}_id"])) {
$this->entries["{$this->table}_id"] = $db->insert_id();
}
$this->reset();
}
return;
}
示例4: delete_entry_by_id
public static function delete_entry_by_id($settings_id)
{
// debug::add_info("(".__FILE__.")<b>".__CLASS__."</b>::".__FUNCTION__."($settings_id) betreten.");
$db = database::get_instance();
$settings_id = $db->escape($settings_id);
$sql = "\n\t\t\tDELETE FROM `settings` WHERE `settings_id` = {$settings_id};\n\t\t";
return $db->query($sql);
}
示例5: get_all_entries_ordered
public static function get_all_entries_ordered()
{
// debug::add_info("(".__FILE__.")<b>".__CLASS__."</b>::".__FUNCTION__."() betreten.");
$db = database::get_instance();
$sql = "\n\t\t\tSELECT r.*, p.awards, p.avatar, p.avatar_mime FROM `ranking2016` r\n LEFT JOIN `player2016` p USING(playername)\n WHERE TRUE\n ORDER by r.crptotal desc;\n\t\t";
//debug::add_info("sql:<br /><pre>$sql</pre>");
return $db->get_objects($sql, __CLASS__);
}
示例6: get_points_by_player_month
public static function get_points_by_player_month($player, $month)
{
$db = database::get_instance();
$player = $db->escape($player);
$month = $db->escape($month);
$sql = "\n SELECT sum(points) as points FROM upload2016\n\t\t\tWHERE \n\t\t\tplayername = '{$player}' AND\n\t\t\tmonth = '{$month}'\n GROUP BY playername ORDER BY points DESC;\n\t\t";
//debug::add_info("sql:<br /><pre>$sql</pre>");
return $db->get_assoc($sql);
}
示例7: remove_by_filter
public static function remove_by_filter($table, $filter = array())
{
$db = database::get_instance();
$query = "\n\t\t\t\tDELETE\n\t\t\t\tFROM\t{$table}\n\t\t\t\tWHERE\tTRUE\n\t\t\t";
foreach ($filter as $field => $value) {
$value = $db->escape($value);
$option = $value == 'NULL' || is_null($value) ? "(`{$field}` IS NULL OR `{$field}` = '0')" : "`{$field}` = '{$value}'";
$query .= " AND {$option}";
}
return $db->query($query);
}
示例8: __construct
public function __construct()
{
$this->db = database::get_instance();
$this->table = '';
$this->field = '*';
$this->where = '';
$this->order = '';
$this->page_size = 0;
$this->page = 1;
$this->page_sum = 1;
}
示例9: User_login
public function User_login($table, $col_1, $col_2, $input_1, $input_2, $type)
{
$input = Input::all();
Session::put('table', $table);
$inputs = array($col_1 => $input[$input_1], $col_2 => $input[$input_2]);
if (Auth::attempt($inputs)) {
$object = database::get_instance();
$val = array('user_session' => $input[$input_1], 'type' => $type);
$object->add('users_login', $val);
return Redirect::to('/');
} else {
return Redirect::to('/')->with('exists', 'Wrong E-Mail Or Password');
}
}
示例10:
@extends('../includes/sidebar')
@section('content')
<?php
/*get the id from session*/
$id = Session::get('update_department');
/*select tha data that id has it*/
$view_department = database::get_instance();
$user = $view_department->view('department', 'where_first', 'id', '=', $id, '');
?>
<div class="row">
<div class="col-md-12">
<div class="panel panel-primary" data-collapsed="0">
<div class="panel-heading">
<div class="panel-title">
<h2>Update department</h2>
</div>
</div>
<div class="panel-body">
<form role="form" class="form-horizontal form-groups-bordered" method="post" enctype="multipart/form-data" action="update_department=<?php
echo $id;
?>
示例11:
<th class="sorting" role="columnheader" tabindex="0" aria-controls="table-1" rowspan="1" colspan="1" aria-label="CSS grade: activate to sort column ascending">
Number of course houres
</th>
<th class="sorting" role="columnheader" tabindex="0" aria-controls="table-1" rowspan="1" colspan="1" aria-label="CSS grade: activate to sort column ascending">
Course Type
</th>
<th class="sorting" role="columnheader" tabindex="0" aria-controls="table-1" rowspan="1" colspan="1" aria-label="CSS grade: activate to sort column ascending">
Action
</th>
</tr>
</thead>
<tbody role="alert" aria-live="polite" aria-relevant="all">
<?php
$view_course = database::get_instance();
$courses = $view_course->view('course', ' ', ' ', " ", ' ', '');
foreach ($courses as $dep) {
$department = $view_course->view('department', "where_first", 'id', '=', "{$dep->department}", '');
?>
<tr class="gradeA odd">
<td class=" "><?php
echo $dep->id;
?>
</td>
<td class=" "><?php
echo $dep->name;
?>
</td>
<td class=" "><?php
示例12: download_homework
public function download_homework($id)
{
$object = database::get_instance();
$user = $object->view("student_assignment", "where_first", 'id', '=', "{$id}", '');
$name_of_file = $user->student_assignment;
$file = public_path() . "/assets/assignment_upload/{$name_of_file}";
$file_name_extension = $name_of_file;
return Response::download($file, "{$file_name_extension}");
}
示例13:
<div class="panel panel-primary" data-collapsed="0">
<div class="panel-heading">
<div class="panel-title">
<h2>View Uploaded Assignment</h2>
</div>
</div>
<div class="panel-body">
<div class="row">
<?php
/*select all fields*/
$view_fields = database::get_instance();
$users = DB::table('users_login')->orderBy('id', 'desc')->first();
$id = $view_fields->view('professor', "where_pluck", 'Mail', '=', $users->user_session, 'id');
$courses = $view_fields->view('prof_course', 'where_get', 'prof_id', '=', $id, '', '');
?>
<div class="form-group">
<label class="col-sm-2 control-label" style="
margin-top: 9px;
">All Courses</label>
<div class="col-sm-9">
示例14: elseif
@extends('../includes/sidebar')
@section('content')
<?php
$users = DB::table('users_login')->orderBy('id', 'desc')->first();
$mail = $users->user_session;
$person_type = $users->type;
$id = '';
$object = database::get_instance();
$table = '';
if ($person_type == 'Administrator') {
$table = 'admin';
$id = $object->view('admin', "where_pluck", 'mail', '=', $mail, 'id');
} elseif ($person_type == 'Professor') {
$table = 'professor';
$id = $object->view('professor', "where_pluck", 'Mail', '=', $mail, 'id');
} elseif ($person_type == 'Teacher') {
$table = 'teacher';
$id = $object->view('teacher', "where_pluck", 'Mail', '=', $mail, 'id');
} elseif ($person_type == 'Student') {
$table = 'students';
$id = $object->view('students', "where_pluck", 'stu_id', '=', $mail, 'id');
}
?>
<?php
$success = Session::get('success');
?>
@if($success)
<div class="alert alert-success">
<center>{{ $success }}</center>
</div>
示例15: upload_solution
public function upload_solution($id)
{
$object = database::get_instance();
$users = DB::table('users_login')->orderBy('id', 'desc')->first();
$stu_id = $users->user_session;
$student_id = $object->view('students', "where_pluck", 'stu_id', '=', $stu_id, 'id');
$ass_id = Input::get('assignment_id');
$file = Input::file('upload_assignment');
$destinationPath = "/wamp/www/GradeSystem/public/assets/assignment_upload";
$filename = str_random(6) . '_' . $file->getClientOriginalName();
$uploadSuccess = $file->move($destinationPath, $filename);
$val = array('student_id' => $student_id, 'assignment_id' => $ass_id, 'student_assignment' => $filename);
$object->add('student_assignment', $val);
return Redirect::to("view_student_assignment=" . $id)->with('success', 'You successfully upload assignment.');
}