本文整理汇总了PHP中Photograph::find_by_id方法的典型用法代码示例。如果您正苦于以下问题:PHP Photograph::find_by_id方法的具体用法?PHP Photograph::find_by_id怎么用?PHP Photograph::find_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Photograph
的用法示例。
在下文中一共展示了Photograph::find_by_id方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: comment_mail_notification
public function comment_mail_notification()
{
$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = SMTP_HOST;
$mail->SMTPAuth = SMTP_AUTH;
$mail->Username = SMTP_USER;
$mail->Password = SMTP_PASS;
$mail->SMTPSecure = SMTP_SECURE;
$mail->Port = SMTP_PORT;
$mail->From = SMTP_FROM;
$mail->FromName = SMTP_FROM_NAME;
$mail->addReplyTo(SMTP_REPLY_TO, SMTP_REPLY_TO_NAME);
$mail->addAddress(SMTP_TO, SMTP_TO_NAME);
$mail->isHTML(SMTP_ISHTML);
$mail->Subject = SMTP_SUBJECT . strftime("%T", time());
$created = datetime_to_text($this->created);
$mail_body = nl2br($this->body);
$photo = Photograph::find_by_id($_GET['id']);
$mail->Body = <<<EMAILBODY
A new comment has been received in the Photo Gallery.<br>
<br>
Photograph: {$photo->filename}<br>
<br>
On {$created}, {$this->author} wrote:<br>
<br>
{$mail_body}<br>
EMAILBODY;
$result = $mail->send();
return $result;
}
示例2: redirect_to
<?php
require_once "../includes/initialize.php";
if (empty($_GET['id'])) {
$session->message("No photograph id was provided");
redirect_to(index . php);
}
$photo = Photograph::find_by_id($_GET['id']);
if (!$photo) {
$session->message("The photo could not be located");
redirect_to("index.php");
}
?>
<?php
include_layout_template('header.php');
?>
<a href = "index.php">
« Back
</a>
<br/>
<div style="margin-left:20px;">
<img src = "<?php
echo $photo->image_path();
?>
" />
<p>
<?php
echo $photo->caption;
示例3: redirect_to
<?php
require_once "../../includes/initialize.php";
if (!$session->is_logged_in()) {
redirect_to("login.php");
}
// must hve an ID
if (empty($_GET['id'])) {
$session->message("No photograph ID was provied.");
redirect("index.php");
}
// check if passed photo id exists.
$photo = Photograph::find_by_id($_GET["id"]);
if ($photo && $photo->destory()) {
$session->message("The photo {$photo->filename} was deleted.");
redirect_to("list_photos.php");
} else {
$session->message("The photo could not be deleted.");
redirect_to("list_photos.php");
}
if (isset($database)) {
$database->close_connection();
}
示例4: Photograph
<?php
require_once '../inc/initialize.php';
$photograph = new Photograph();
$photograph_details = $photograph->find_by_id($session->applicant_id);
if ($_FILES['picture']['error'] == 2) {
sleep(2);
echo '<h4 class="alert alert-error">Error</h4>';
echo '<hr>';
echo "Maximum File size Exceeded(250Kb)";
die;
}
if (!empty($photograph_details) && !empty($_FILES['picture']['name'])) {
$photograph->image_id = $photograph_details->image_id;
unlink(SITE_ROOT . DS . 'passport' . DS . $photograph_details->filename);
}
$arrayfiledetails = explode('.', $_FILES['picture']['name']);
$extension = $arrayfiledetails[sizeof($arrayfiledetails) - 1];
$_FILES['picture']['name'] = $session->applicant_id . '.' . $extension;
if ($photograph->attach_file($_FILES['picture'])) {
$photograph->caption = User::applicant_fullname($session->applicant_id);
$photograph->applicant_id = $session->applicant_id;
//explode filename to get file extension
$photograph->filename = $_FILES['picture']['name'];
if ($photograph->save()) {
$user = new User();
$user->applicant_id = $session->applicant_id;
$user->updateProgress('G');
sleep(2);
echo '<h4 class="alert alert-success"><i class="iconic-o-check" style="color: #51A351"></i> Success</h4>';
echo '<hr>';
示例5: redirect
<?php
require_once '../../includes/initialize.php';
if (!$session->is_logged_in()) {
redirect("login.php");
}
if (empty($_GET['id'])) {
$session->set_get_message("Photo's Id Not Selected");
redirect('index.php');
}
$photo = Photograph::find_by_id($database->escape_value($_GET['id']));
if ($photo && $photo->destroy()) {
$session->set_get_message("Photograph {$photo->filename} Deleted Successfully");
redirect('view_photograph.php');
} else {
$session->set_get_message("Photograph Couldn't Be Deleted");
redirect('view_photograph.php');
}
示例6: find_by_sql
<?php
}
?>
</table>
<?php
echo "<hr />";
?>
<!-- Works with the find_by_sql() code that is commented, bad because returns only one data. -->
<!-- <?php
echo "User ID: " . $_SESSION['myid'];
$photos = Photograph::find_by_id($id = 8);
?>
<h2>Photographs</h2>
<table class="bordered">
<tr>
<th>Image</th>
<th>Caption</th>
<th>Size</th>
</tr>
<tr>
<td><img src="<?php
echo "public/" . $photos->image_path();
?>
示例7: comment_mail_notification
public function comment_mail_notification()
{
// This method uses PHPMailer
// See sendmail.php for using PHP's standard built in mail() function
$mail = new PHPMailer();
// phpMailer reporting
$mail->SMTPDebug = 3;
// You can leave out the following section and PHPMailer will still function as a
// class and mehtod, as detailed below, but will use the standard PHP Sendmail function.
// In order to utilise the SMTP features of PHPMailer, set isSMTP() and your server details.
// SMTP sending server configs
$mail->isSMTP();
// Set mailer to use SMTP
$mail->Host = SMTP_HOST;
// Specify main and backup SMTP servers
$mail->SMTPAuth = SMTP_AUTH;
// Enable SMTP authentication
$mail->Username = SMTP_USER;
// SMTP username
$mail->Password = SMTP_PASS;
// SMTP password
$mail->SMTPSecure = SMTP_SECURE;
// Enable TLS encryption, `ssl` also accepted
$mail->Port = SMTP_PORT;
// TCP port to connect to
// End of SMTP Configs
// FROM: details
$mail->From = SMTP_FROM;
$mail->FromName = SMTP_FROMNAME;
// Reply-To (if different)
$mail->addReplyTo('user@domain.com', 'User Name');
// $to_name = "User Name";
// $to = "user@domain.com";
// TO: details
// $mail->addAddress($to, $to_name)
$mail->addAddress('user@domain.com', 'User Name');
// Add a recipient
// $mail->addAddress('ellen@example.com'); // Name is optional
// $mail->addCC('cc@example.com');
// $mail->addBCC('bcc@example.com');
// Attachments
// $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
// Mail format
$mail->isHTML(SMTP_ISHTML);
// Set email format to HTML
// Mail Subject
$mail->Subject = SMTP_SUBJECT . strftime("%T", time());
// Mail Body
// $mail->Body = 'A new comment has been received.';
// $mail->AltBody = 'A new comment has been received.';
// Format the created time more nicely.
$created = datetime_to_text($this->created);
// Ensure line endings are preserved even in HEREDOC HTML email output.
$mail_body = nl2br($this->body);
// Get all the photo attributes so we can use them in the email
$photo = Photograph::find_by_id($_GET['id']);
// Generate the email body with HEREDOC
$mail->Body = <<<EMAILBODY
A new comment has been received in the Photo Gallery.<br>
<br>
Photograph: {$photo->filename}<br>
<br>
On {$created}, {$this->author} wrote:<br>
<br>
{$mail_body}<br>
EMAILBODY;
// Process mail and Status feedback
// if(!$mail->send()) {
// echo 'Message could not be sent.';
// echo 'Mailer Error: ' . $mail->ErrorInfo;
// } else {
// echo '<br><br><hr>';
// echo 'Message has been sent';
// }
// Alternate process with no feedback
$result = $mail->send();
return $result;
}
示例8: redirect_to
<?php
require_once "../../includes/initialize.php";
if (!$session->is_logged_in()) {
redirect_to("login.php");
}
if (empty($_GET['photo_id'])) {
$session->message("No photo ID was provided, therefore cannot find.");
redirect_to("list_photo.php");
}
$photo = Photograph::find_by_id((int) $_GET['photo_id']);
if (!$photo) {
$session->message("Photo object cannot be found in database.");
redirect_to("index.php");
}
$comments = $photo->comments();
?>
<?php
include_layout_template("admin_header.php");
?>
«<a href="index.php">Admin Home</a>
<br>
«<a href="list_photo.php">List Photos</a>
<br>
<!-- Photo -->
<?php
echo output_message($message);
?>
<h2>Comments on: <?php
echo $photo->filename;