本文整理汇总了PHP中Query::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::where方法的具体用法?PHP Query::where怎么用?PHP Query::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Query
的用法示例。
在下文中一共展示了Query::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extractWhereDef
private function extractWhereDef(Query $query, $args)
{
if (sizeof($args) === 1) {
$query->where($args[0]);
} else {
$query->where($args[0], $args[1]);
}
}
示例2: scopeEligibleParents
/**
* Limit results to only records that are eligible to be parents of the provided model.
* Ineligible parents include: The provided model itself, models with the provided model
* as it's own parent already, and a model that is already the current model's parent
*
* @param Query $query
* @param Model $model The model to check for eligible parents against
* @return Query
*/
public function scopeEligibleParents($query, $model)
{
$query->where('id', '!=', $model->id)->where(function ($query) use($model) {
$query->where('parent_id', '!=', $model->id)->orWhereNull('parent_id');
});
if ($model->parent_id) {
$query->where('id', '!=', $model->parent_id);
}
return $query;
}
示例3: Query
function cnt_by_opt($_tid, $_cid, $_where = '')
{
// $this->debug();
$c = new Query();
$c->from = "recruit r, recruit_opt ro";
$c->where("ro.recruit_id = r.id");
$c->where_eq("code_type", $_tid);
$c->where_eq("code_id", $_cid);
if ($_where) {
$c->where($_where);
}
$res = $this->counts($c);
return $res;
}
示例4: article
public function article($id)
{
$query = new Query();
$query->where(["id = {$id}"]);
$post = $query->findOne('Posts');
$this->render('article.html.twig', array('post' => $post));
}
示例5: filterQuery
/**
* Filters a query object
*
* @param Query $query
* @param Eloquent $model
*
* @return void
*/
public function filterQuery(&$query, $model)
{
//if the field is
if ($this->value !== '') {
$query->where($model->table() . '.' . $this->field, '=', $this->value);
}
}
示例6: 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);
}
示例7: testShouldGenerateSelectWithWhere
public function testShouldGenerateSelectWithWhere()
{
$query = new Query('users');
$expected = "SELECT * FROM users WHERE username = 'Mario';";
$query->where("username = 'Mario'");
$result = $query->generate();
$this->assertEquals($expected, $result);
}
示例8: cnt
function cnt($_where)
{
$c = new Query();
if ($_where) {
$c->where($_where);
}
return $this->counts();
}
示例9: Query
function get_by_member($_user)
{
$c = new Query();
$c->from = "startup_local sl, local l";
$c->where("sl.local_id = l.id");
$c->where_eq("startup_id", $_user);
$res = $this->fetch("*", $c);
return $res;
}
示例10: cnt
function cnt($_where = '')
{
// $this->debug();
$c = new Query();
if ($_where) {
$c->where($_where);
}
return $this->counts($c);
}
示例11: Query
function get_by_member_c($_user)
{
$c = new Query();
$c->from = "member_local ml, code c";
$c->where("ml.local_id = c.id");
$c->where_eq("user_id", $_user);
$res = $this->fetch("*", $c);
return $res;
}
示例12: Query
function list_($_user)
{
$c = new Query();
$c->from = "member_project mp, startup s";
$c->where("mp.startup_id = s.id");
$c->where_eq("user_id", $_user);
$c->order = "mp.id ASC";
$res = $this->fetch("mp.*, s.name", $c);
return $res;
}
示例13: Query
function list_($_page, $_pagesize, $_where = '', $_order = '')
{
// $this->debug();
$c = new Query();
$c->from = "members m, member_grade mg, member_interist mi";
$c->where("mg.id = m.grade");
$c->where("mi.user_id = m.id");
if ($_where) {
$c->where($_where);
}
if ($_order) {
$c->order = $_order;
} else {
$c->order = "m.id DESC";
}
$c->page = $_page;
$c->page_size = $_pagesize;
$res = $this->fetch("m.*, mg.name gname", $c);
return $res;
}
示例14: Query
function get_by_form_res_user($_fid, $_aid)
{
// $this->debug();
$c = new Query();
$c->from = "competitions_form_res cfr, competitions_form cf";
$c->where("cf.id = cfr.c_form_id");
$c->where_eq("c_form_id", $_fid);
$c->where_eq("apply_id", $_aid);
$res = $this->fetch_one("*", $c);
return $res;
}
示例15: getElectives
static function getElectives($program, $elective_type, $elective_group, $exclude = [])
{
$results = array();
foreach (explode("|", $elective_group) as $group) {
$q = new Query("electives");
$q->select("course_code");
$q->where("program_id=?\n\t\t\t\t\t\t\tAND elective_type=?\n\t\t\t\t\t\t\tAND note=?\n\t\t\t\t\t\t\tAND course_code NOT IN " . Query::valuelistsql($exclude), array_merge([$program, $elective_type, $group], $exclude));
$results = array_merge($results, $q->executeFetchAll());
}
return $results;
}