本文整理汇总了PHP中Entry::findByID方法的典型用法代码示例。如果您正苦于以下问题:PHP Entry::findByID方法的具体用法?PHP Entry::findByID怎么用?PHP Entry::findByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entry
的用法示例。
在下文中一共展示了Entry::findByID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRange
public static function getRange($start_date, $end_date)
{
$mysqli = new mysqli("localhost", "root", "password", "426project");
$query = "SELECT id FROM entries WHERE created_at >= '{$start_date}' AND created_at <= '{$end_date}' ORDER BY created_at";
console_log($query);
$result = $mysqli->query($query);
$entries = array();
if ($result) {
for ($i = 1; $i < $start; $i++) {
$result->fetch_row();
}
for ($i = $start; $i <= $end; $i++) {
$next_row = $result->fetch_row();
if ($next_row) {
$entries[] = Entry::findByID($next_row[0]);
}
}
}
return $entries;
}
示例2: json_encode
// console_log(Entry::getRange($new_start_date->format('Y-m-d'), $new_end_date->format('Y-m-d')));
print json_encode(Entry::getRange($new_start_date->format('Y-m-d'), $new_end_date->format('Y-m-d')));
exit;
}
// ID not specified, then must be asking for index
header("Content-type: application/json");
print json_encode(Entry::getAllIDs());
exit;
} else {
if ($_SERVER['REQUEST_METHOD'] == "POST") {
// Either creating or updating
// Following matches /entry.php/<id> form
if (count($path_components) >= 2 && $path_components[1] != "") {
//Interpret <id> as integer and look up via ORM
$entry_id = intval($path_components[1]);
$entry = Entry::findByID($entry_idy);
if ($entry == null) {
// Entry not found.
header("HTTP/1.0 404 Not Found");
print "Entry id: " . $entry_id . " not found while attempting update.";
exit;
}
// Validate values
$new_author_id = false;
if (isset($_REQUEST['author_id'])) {
$new_author_id = trim($_REQUEST['author_id']);
if ($new_author_id == 0) {
header("HTTP/1.0 400 Bad Request");
print "Can't save an entry without an author! (Please log in or register)";
exit;
}