本文整理汇总了PHP中Query::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::get方法的具体用法?PHP Query::get怎么用?PHP Query::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Query
的用法示例。
在下文中一共展示了Query::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('holidays')->delete();
$db = App::make('AccessDB');
$query = new Query('HOLIDAYS', $db->get_dbh());
$query->where('DURATION', '>', 0);
$result = $query->get('HOLIDAYID,STARTTIME,DURATION');
$result_array = [];
foreach ($result as $row) {
$start_time = strtotime($row['STARTTIME']);
$duration = $row['DURATION'] - 1;
$end_time = strtotime("+{$duration} days", $start_time);
$result_array[] = ['id' => $row['HOLIDAYID'], 'start' => $row['STARTTIME'], 'duration' => $row['DURATION'], 'end' => date('Y-m-d H:i:s', $end_time)];
}
$holiday = array_chunk($result_array, 1000);
foreach ($holiday as $value) {
Holiday::insert($value);
}
$convert_file = public_path() . '\\Last Convert.txt';
$record = explode(';', file_get_contents($convert_file));
$record[2] = $result[count($result) - 1]['HOLIDAYID'];
$file = fopen($convert_file, 'w');
fwrite($file, implode(';', $record));
fclose($file);
}
示例2: getData
/**
* get an array of data to use in the response
* @param Query $query the query to use to retrieve the data
* @param Paginator $paginator
* @param array $additionalData an associative array of data to merge with the data array
*/
protected function getData($query, $additionalData = array())
{
//use this hook to alter the parameters
$paginator = null;
if (Input::get('page') || $this->paginate) {
$beforePagination = Event::fire('before.pagination', array(&$query));
//check if $object is a model or a relation
$model = $query->getModel();
$model = method_exists($model, 'getRelated') ? $model->getRelated() : $model;
$perPage = Input::get('pp') ?: $model->getPerPage();
$paginator = $query->paginate($perPage);
//preserve the url query in the paginator
$paginator->appends(Input::except('page'));
}
$results = isset($paginator) ? $paginator->getCollection() : $query->get();
$data = array();
$data[$this->resultsKey] = $this->isAjaxRequest() ? $results->toArray() : $results;
$data['total'] = isset($paginator) ? $paginator->getTotal() : $data->{$this->resultsKey}->count();
if ($paginator) {
$data['paginator'] = $paginator;
}
if (is_array($additionalData)) {
$data = array_merge($data, $additionalData);
}
return $data;
}
示例3: widget
public function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base);
if (empty($instance['number']) || !($number = absint($instance['number']))) {
$number = 10;
}
$r = new Query(apply_filters('widget_posts_args', array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true)));
return View::make('widgets.recentpost', ['posts' => $r->get(), 'title' => $title])->render();
}
示例4: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('departments')->delete();
$db = App::make('AccessDB');
$query = new Query('DEPARTMENTS', $db->get_dbh());
$result = $query->get('DEPTID,DEPTNAME,SUPDEPTID');
$result_array = [];
foreach ($result as $row) {
$result_array[] = ['id' => $row['DEPTID'], 'name' => $row['DEPTNAME'], 'super_department_id' => $row['SUPDEPTID']];
}
$department = array_chunk($result_array, 1000);
foreach ($department as $value) {
Department::insert($value);
}
}
示例5: create_item
public function create_item($request)
{
$params = $request->get_params();
$problem_id = $params['problem_id'];
$content = $params['content'];
$tried = $params['tried'];
$problem_data = null;
if (isset($params['post_data_key'])) {
$post_data_key = $params['post_data_key'];
$problem_data = get_option($post_data_key);
// Don't ever keep this data around.
delete_option($post_data_key);
}
// Try fetching another question from the same problem.
if (!$problem_data) {
$query = new Query(array('problem_id' => $problem_id));
$questions = $query->get();
foreach ($questions as $q) {
if ($q->get_problem_text()) {
$problem_data = array('problem_id' => $q->get_problem_id(), 'problem_set' => $q->get_problem_set(), 'course' => $q->get_course(), 'section' => $q->get_section(), 'problem_text' => $q->get_problem_text());
break;
}
}
}
$question = new \WeBWorK\Server\Question();
$question->set_author_id(get_current_user_id());
$question->set_content($content);
$question->set_tried($tried);
$question->set_problem_id($problem_data['problem_id']);
$question->set_problem_set($problem_data['problem_set']);
$question->set_course($problem_data['course']);
$question->set_section($problem_data['section']);
$question->set_problem_text($problem_data['problem_text']);
if ($question->save()) {
$query = new Query(array('question_id' => $question->get_id()));
$results = $query->get_for_endpoint();
// @todo not found?
$retval = reset($results);
$r = rest_ensure_response($retval);
$r->set_status(201);
} else {
$r = rest_ensure_response(false);
$r->set_status(500);
}
return $r;
}
示例6: get
/**
* Get responses.
*
* @since 1.0.0
*
* @return array|int
*/
public function get()
{
$args = array('post_type' => 'webwork_response', 'update_post_term_cache' => false, 'meta_query' => array(), 'posts_per_page' => -1, 'orderby' => 'post_date', 'order' => 'ASC');
if (null !== $this->r['question_id__in']) {
if (array() === $this->r['question_id__in']) {
$question_id__in = array(0);
} else {
$question_id__in = array_map('intval', $this->r['question_id__in']);
}
$args['meta_query']['question_id__in'] = array('key' => 'webwork_question_id', 'value' => $question_id__in, 'compare' => 'IN');
}
if (null !== $this->r['is_answer']) {
if ($this->r['is_answer']) {
$args['meta_query']['is_answer'] = array('key' => 'webwork_question_answer', 'value' => '1');
} else {
// SOS
$is_answer_args = $this->r;
$is_answer_args['is_answer'] = true;
$is_answer_args['orderby'] = 'post_date';
$is_answer_query = new Query($is_answer_args);
$is_answers = $is_answer_query->get();
$not_in = array();
foreach ($is_answers as $is_answer) {
$not_in[] = $is_answer->get_id();
}
$args['post__not_in'] = $not_in;
}
}
if ('votes' === $this->r['orderby']) {
$args['meta_query']['votes_orderby'] = array('key' => 'webwork_vote_count', 'compare' => 'EXISTS', 'type' => 'SIGNED');
$args['orderby'] = array('votes_orderby' => 'DESC', 'post_date' => 'ASC');
}
$response_query = new \WP_Query($args);
$_responses = $response_query->posts;
$responses = array();
foreach ($_responses as $_response) {
$responses[$_response->ID] = new \WeBWorK\Server\Response($_response->ID);
}
return $responses;
}
示例7: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('employees')->delete();
$db = App::make('AccessDB');
$query = new Query('USERINFO', $db->get_dbh());
$query->order('USERID');
$result = $query->get('USERID,SSN,Name,Gender,BIRTHDAY,street,DEFAULTDEPTID');
$result_array = [];
foreach ($result as $row) {
$result_array[] = ['id' => $row['USERID'], 'ssn' => $row['SSN'], 'name' => $row['Name'], 'is_male' => $row['Gender'] == 'Male' ? 1 : 0, 'birthday' => $row['BIRTHDAY'], 'street' => $row['street'], 'department_id' => $row['DEFAULTDEPTID']];
}
$employee = array_chunk($result_array, 1000);
foreach ($employee as $value) {
Employee::insert($value);
}
$convert_file = public_path() . '\\Last Convert.txt';
$record = explode(';', file_get_contents($convert_file));
$record[7] = $result[count($result) - 1]['USERID'];
$file = fopen($convert_file, 'w');
fwrite($file, implode(';', $record));
fclose($file);
}
示例8: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('schedules')->delete();
$db = App::make('AccessDB');
$query = new Query('USER_OF_RUN', $db->get_dbh());
$query->order('STARTDATE');
$result = $query->get('STARTDATE,ENDDATE,USERID,NUM_OF_RUN_ID');
$result_array = [];
foreach ($result as $row) {
$result_array[] = ['start_date' => $row['STARTDATE'], 'end_date' => $row['ENDDATE'], 'employee_id' => $row['USERID'], 'weekly_schedule_id' => $row['NUM_OF_RUN_ID']];
}
$schedule = array_chunk($result_array, 1000);
foreach ($schedule as $value) {
Schedule::insert($value);
}
$convert_file = public_path() . '\\Last Convert.txt';
$record = explode(';', file_get_contents($convert_file));
$record[5] = $result[count($result) - 1]['STARTDATE'];
$file = fopen($convert_file, 'w');
fwrite($file, implode(';', $record));
fclose($file);
}
示例9: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('daily_schedules')->delete();
$db = App::make('AccessDB');
$query = new Query('SCHCLASS', $db->get_dbh());
$query->order('SCHCLASSID');
$result = $query->get('SCHCLASSID,SCHNAME,STARTTIME,ENDTIME');
$result_array = [];
foreach ($result as $row) {
$result_array[] = ['id' => $row['SCHCLASSID'], 'name' => $row['SCHNAME'], 'start_time' => $row['STARTTIME'], 'end_time' => $row['ENDTIME']];
}
$daily_schedule = array_chunk($result_array, 1000);
foreach ($daily_schedule as $value) {
DailySchedule::insert($value);
}
$convert_file = public_path() . '\\Last Convert.txt';
$record = explode(';', file_get_contents($convert_file));
$record[4] = $result[count($result) - 1]['SCHCLASSID'];
$file = fopen($convert_file, 'w');
fwrite($file, implode(';', $record));
fclose($file);
}
示例10: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('manual_checks')->delete();
$db = App::make('AccessDB');
$query = new Query('CHECKEXACT', $db->get_dbh());
$query->where('EXACTID', '>=', 1455);
$query->order('EXACTID');
$result = $query->get('EXACTID,USERID,CHECKTIME,CHECKTYPE');
$result_array = [];
foreach ($result as $row) {
$result_array[] = ['date_time' => $row['CHECKTIME'], 'is_in' => $row['CHECKTYPE'] == 'I' ? 1 : 0, 'employee_id' => $row['USERID']];
}
$manual_check = array_chunk($result_array, 1000);
foreach ($manual_check as $value) {
ManualCheck::insert($value);
}
$convert_file = public_path() . '\\Last Convert.txt';
$record = explode(';', file_get_contents($convert_file));
$record[0] = $result[count($result) - 1]['EXACTID'];
$file = fopen($convert_file, 'w');
fwrite($file, implode(';', $record));
fclose($file);
}
示例11: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('absences')->delete();
$db = App::make('AccessDB');
$query = new Query('USER_SPEDAY', $db->get_dbh());
$query->where('STARTSPECDAY', '>=', '2014-07-01');
$query->order('DATE,STARTSPECDAY');
$result = $query->get();
$result_array = [];
foreach ($result as $row) {
$result_array[] = ['start_date' => $row['STARTSPECDAY'], 'end_date' => $row['ENDSPECDAY'], 'reason' => isset($row['YUANYING']) ? $row['YUANYING'] : '', 'employee_id' => $row['USERID'], 'absence_category_id' => $row['DATEID']];
}
$absence = array_chunk($result_array, 1000);
foreach ($absence as $value) {
Absence::insert($value);
}
$convert_file = public_path() . '\\Last Convert.txt';
$record = explode(';', file_get_contents($convert_file));
$record[6] = $result[count($result) - 1]['DATE'];
$file = fopen($convert_file, 'w');
fwrite($file, implode(';', $record));
fclose($file);
}
示例12: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('weekly_schedules')->delete();
$db = App::make('AccessDB');
$query = new Query('NUM_RUN_DEIL', $db->get_dbh());
$query->order('NUM_RUNID');
$result = $query->get('NUM_RUNID,STARTTIME,ENDTIME,SDAYS,EDAYS,SCHCLASSID');
$result_array = [];
foreach ($result as $row) {
$allowance_id = 0;
if ($row['SDAYS'] != 6) {
$end = date_parse($row['ENDTIME']);
$start = date_parse($row['STARTTIME']);
$duration = (mktime($end['hour'], $end['minute']) - mktime($start['hour'], $start['minute'])) / 3600;
if ($duration >= 8) {
$allowance_id = 1;
} else {
if ($duration < 7) {
$allowance_id = 3;
} else {
$allowance_id = 2;
}
}
}
$result_array[] = ['id' => $row['NUM_RUNID'], 'start_day' => $row['SDAYS'], 'end_day' => $row['EDAYS'], 'daily_schedule_id' => $row['SCHCLASSID'], 'allowance_id' => $allowance_id];
}
$weekly_schedule = array_chunk($result_array, 1000);
foreach ($weekly_schedule as $value) {
WeeklySchedule::insert($value);
}
$convert_file = public_path() . '\\Last Convert.txt';
$record = explode(';', file_get_contents($convert_file));
$record[3] = $result[count($result) - 1]['NUM_RUNID'];
$file = fopen($convert_file, 'w');
fwrite($file, implode(';', $record));
fclose($file);
}
示例13: all
/**
* Return a list of all published posts.
*
* @return array
*/
public static function all()
{
$query = new Query(['post_type' => 'galleries', 'posts_per_page' => -1, 'post_status' => 'publish']);
return $query->get();
}
示例14: get
/**
* Make sure the soft-filter is added to get() calls
*/
public function get()
{
$this->add_soft_filter();
return parent::get();
}
示例15: getAdmin
public function getAdmin($conexion, $email, $password)
{
$query = new Query();
return $query->get($this->table, $email, $password, $conexion);
}