本文整理汇总了PHP中Review::get_by_sql方法的典型用法代码示例。如果您正苦于以下问题:PHP Review::get_by_sql方法的具体用法?PHP Review::get_by_sql怎么用?PHP Review::get_by_sql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Review
的用法示例。
在下文中一共展示了Review::get_by_sql方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
if (count($traffics) > 0) {
foreach ($traffics as $traffic) {
$totaltraffics += $traffic->status;
}
}
$item->averagestatus = true;
$item->trafficcount = count($traffics);
if ($item->trafficcount > 0) {
$item->trafficlevel = $totaltraffics / $item->trafficcount;
}
if (count($traffics) > 0) {
$item->lasttrafficdatetime = $traffics[count($traffics) - 1]->datetime;
}
//---------------------- REVIEWS
$sql = "SELECT * FROM reviews WHERE itemid = " . $item->id . " AND itemtype = store";
$reviews = Review::get_by_sql($sql);
$totalratings += $traffic->status;
if (count($reviews) > 0) {
foreach ($reviews as $review) {
$totalratings += $review->rating;
}
$item->ratings = $totalratings / count($reviews);
}
if (!isset($_GET['blob'])) {
$filename++;
$random = rand(0, 1);
file_put_contents("images/" . $filename . "x" . $random . ".jpg", base64_decode($item->picture));
$item->picture = HOST . "includes/webservices/images/" . $filename . "x" . $random . ".jpg";
}
}
echo str_replace('\\/', '/', json_encode($items));
示例2: equallike
}
if (isset($_GET['enabled'])) {
$where .= " AND " . C_REVIEW_ENABLED . equallike($_GET['enabled'], "int");
}
//======================================================
if (isset($_GET['limit'])) {
$limit = " LIMIT " . $_GET['limit'] . " ";
}
if (isset($_GET['sortby']) && isset($_GET['sortorder'])) {
$sort = " ORDER BY " . $_GET['sortby'] . " " . $_GET['sortorder'] . " ";
}
if (isset($_GET['sortby']) && !isset($_GET['sortorder'])) {
$sort = " ORDER BY " . $_GET['sortby'] . $sortorder . " ";
}
//======================================================
$items = Review::get_by_sql("SELECT * FROM " . T_REVIEWS . " WHERE " . $where . $sort . $limit);
$filename = 0;
if (!isset($_GET['blob'])) {
foreach ($items as $item) {
$filename++;
$random = rand(0, 1);
$user = User::get_by_id($item->userid);
$item->username = $user->get_full_name();
file_put_contents("images/" . $filename . "x" . $random . ".jpg", base64_decode($user->picture));
$item->picture = HOST . "includes/webservices/images/" . $filename . "x" . $random . ".jpg";
}
}
echo str_replace('\\/', '/', json_encode($items));
//echo json_encode($items, JSON_UNESCAPED_SLASHES);
function equallike($field, $type)
{
示例3:
if ($searchOper == 'eq') {
$searchString = $searchString;
}
if ($searchOper == 'bw' || $searchOper == 'bn') {
$searchString .= '%';
}
if ($searchOper == 'ew' || $searchOper == 'en') {
$searchString = '%' . $searchString;
}
if ($searchOper == 'cn' || $searchOper == 'nc' || $searchOper == 'in' || $searchOper == 'ni') {
$searchString = '%' . $searchString . '%';
}
$where = "{$searchField} {$ops} '{$searchString}'";
$objects = Review::get_by_sql("SELECT * FROM " . T_REVIEWS . " WHERE " . $where . " ORDER BY {$sidx} {$sord} LIMIT {$start} , {$limit}");
} else {
$objects = Review::get_by_sql("SELECT * FROM " . T_REVIEWS . " ORDER BY {$sidx} {$sord} LIMIT {$start} , {$limit}");
}
header("Content-type: text/xml;charset=utf-8");
$s = "<?xml version='1.0' encoding='utf-8'?>";
$s .= "<rows>";
$s .= "<page>" . $page . "</page>";
$s .= "<total>" . $total_pages . "</total>";
$s .= "<records>" . $count . "</records>";
foreach ($objects as $object) {
$s .= "<row id='" . $object->id . "'>";
$s .= "<cell></cell>";
$s .= "<cell>" . $object->id . "</cell>";
$s .= "<cell>" . $object->userid . "</cell>";
$s .= "<cell>" . $object->itemid . "</cell>";
$s .= "<cell>" . $object->itemtype . "</cell>";
$s .= "<cell>" . $object->review . "</cell>";