本文整理汇总了PHP中Photograph::find_by_sql方法的典型用法代码示例。如果您正苦于以下问题:PHP Photograph::find_by_sql方法的具体用法?PHP Photograph::find_by_sql怎么用?PHP Photograph::find_by_sql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Photograph
的用法示例。
在下文中一共展示了Photograph::find_by_sql方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLikes
function getLikes($picID)
{
$sqlQuery = "SELECT photograph_id FROM votes ";
$sqlQuery .= "WHERE photograph_id ={$picID}";
$photographsQuery = Photograph::find_by_sql($sqlQuery);
echo sizeof($photographsQuery);
}
示例2: Pagination
// 1. the current page number ($current_page)
$page = !empty($_GET['page']) ? (int) $_GET['page'] : 1;
// 2. records per page ($per_page)
$per_page = 3;
// 3. total record count ($total_count)
$total_count = Photograph::count_all();
// Find all photos
// use pagination instead
//$photos = Photograph::find_all();
$pagination = new Pagination($page, $per_page, $total_count);
// Instead of finding all records, just find the records
// for this page
$sql = "SELECT * FROM photographs ";
$sql .= "LIMIT {$per_page} ";
$sql .= "OFFSET {$pagination->offset()}";
$photos = Photograph::find_by_sql($sql);
// Need to add ?page=$page to all links we want to
// maintain the current page (or store $page in $session)
?>
<?php
include_layout_template('header.php');
?>
<?php
foreach ($photos as $photo) {
?>
<div style="float: left; margin-left: 20px;">
<a href="photo.php?id=<?php
echo $photo->id;
?>
示例3: include_layout_template
require_once '../includes/initialize.php';
?>
<?php
include_layout_template("header.php");
$page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
$record_no = 3;
$total_records = Photograph::count();
// $photo_object = new Photograph();
// $photos = $photo_object->find_all();
$pagination = new Pagination($page, $record_no, $total_records);
$sql_query = "SELECT * FROM photograph ";
$sql_query .= "LIMIT {$record_no} ";
$sql_query .= "OFFSET {$pagination->offset()} ";
$photos = Photograph::find_by_sql($sql_query);
?>
<h2>Photos</h2>
<?php
echo output_message($session->set_get_message());
?>
<?php
foreach ($photos as $photo) {
?>
<div style="float:left;margin-left: 20px; display:inline;">
<a href="photo.php?id=<?php
echo $photo->id;
?>
">
<img src="<?php
echo $photo->image_path();
示例4: foreach
<?php
require_once '../includes/includes_all.php';
$cat = !empty($_GET['cat']) ? (int) $_GET['cat'] : 1;
$qry = "select * from tblimages where cat_id={$cat}";
$photos = Photograph::find_by_sql($qry);
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="stylesheets/style.css"/>
<title>Wallpaper Hub</title>
</head>
<body>
<div id="main">
<?php
include_layout_template('header.php');
?>
<?php
include_layout_template('menu.php');
?>
<div id="contents" >
<div style="width:99%; padding:5px;" >
<?php
if ($session->is_logged_in()) {
?>
<?php
foreach ($photos as $photo) {
?>
<a href="<?php
echo $photo->image_path();
?>
示例5: MySQLDatabase
<?php
$database = new MySQLDatabase();
$session = new Session();
$photo_details = Photograph::find_by_sql("SELECT * FROM photographs WHERE applicant_id=" . $session->applicant_id);
foreach ($photo_details as $photo_detail) {
$photo_detail->image_id;
$photo_detail->applicant_id;
$photo_detail->filename;
$photo_detail->type;
$photo_detail->size;
$photo_detail->caption;
}
?>
<form action="" method="POST" id="passportupload" >
<?php
if ($photo_detail->applicant_id == $session->applicant_id) {
?>
<table align="center">
<tr><td align="center">
<span style="color: #09F; font-weight: bold; text-shadow: 1px 1px 4px #F89406"><i class="iconic-user"></i> <?php
echo $photo_detail->caption;
?>
</span>
</td></tr>
<tr><td> </td></tr>
<tr>
<td>
<div class="control-group">