本文整理汇总了PHP中Photo::find_by_id方法的典型用法代码示例。如果您正苦于以下问题:PHP Photo::find_by_id方法的具体用法?PHP Photo::find_by_id怎么用?PHP Photo::find_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Photo
的用法示例。
在下文中一共展示了Photo::find_by_id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display_sidebar
public static function display_sidebar($photo_id)
{
$photo = Photo::find_by_id($photo_id);
$output = "<a class='thumbnail' href='#'><img width='100' src='{$photo->picture_path()}' ></a>";
$output .= "<p>{$photo->filename}</p>";
$output .= "<p>{$photo->type}</p>";
$output .= "<p>{$photo->size}</p>";
echo $output;
}
示例2: redirect_to
<?php
include "includes/header.php";
if (!$session->is_signed_in()) {
redirect_to("login.php");
}
if (empty($_GET['id'])) {
redirect_to("photos.php");
} else {
$photo = Photo::find_by_id($_GET['id']);
if (isset($_POST['update'])) {
if ($photo) {
$photo->title = $_POST['title'];
$photo->caption = $_POST['caption'];
$photo->alternate_text = $_POST['alternate_text'];
$photo->description = $_POST['description'];
$photo->save();
}
}
}
?>
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<?php
include 'includes/top_nav.php';
?>
<!-- Sidebar Menu Items - These collapse to the responsive navigation menu on small screens -->
<?php
include "includes/side_nav.php";
示例3: redirect
<?php
include "includes/init.php";
if (!$session->is_signed_in()) {
redirect('login.php');
}
if (empty($_GET['id']) && !isset($_GET['id'])) {
redirect("photos.php");
}
$id = urldecode($_GET['id']);
$photo = Photo::find_by_id($id);
if ($photo && file_exists($photo->full_path_directory . DS . $photo->filename)) {
$photo->delete_picture();
redirect("photos.php");
} else {
redirect("photos.php");
}
示例4: foreach
<th>ID</th>
<!-- <th>Photo</th>-->
<th>Author</th>
<th>Comment</th>
<th>Date tine</th>
<th colspan="2" class="text-center">Action</th>
</tr>
</thead>
<tbody>
<?php
$comments = Comment::find_all();
$output = "";
$blank = " ";
foreach ($comments as $comment) {
$photo = Photo::find_by_id($comment->photo_id);
$output .= "<tr>";
$output .= "<td>{$comment->id}</td>";
// $output.="<td style='text-center'><img class='user-image' src=\"{$photo->picture_path()}\" alt=''></td>";
$output .= "<td>{$comment->author}</td>";
$output .= "<td>{$comment->body}</td>";
$output .= "<td>" . strftime("%d %M %Y @ %Hh%M", strtotime($comment->input_date)) . "</td>";
$output .= "<td class='text-center'><a class='btn btn-danger btn-xs page-table-action' href='delete_comment.php?id=" . urlencode($comment->id) . "'>Delete</a></td>{$blank}";
$output .= "<td class='text-center'><a class='btn btn-primary btn-xs btn-xs page-table-action' href='edit_comment.php?id=" . urlencode($comment->id) . "'>Edit</a></td>{$blank}";
$output .= "</tr>";
}
unset($photo);
echo $output;
?>
示例5: array
<?php
require "init.php";
$image_info = array();
$photo = Photo::find_by_id($_POST['image_id']);
$image_info['filename'] = $photo->filename;
$image_info['type'] = $photo->type;
$image_info['size'] = $photo->size;
echo json_encode($image_info);