本文整理汇总了PHP中Blog::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Blog::find方法的具体用法?PHP Blog::find怎么用?PHP Blog::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Blog
的用法示例。
在下文中一共展示了Blog::find方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: view
public function view($query)
{
$blog = new Blog();
$params = array('blog' => $blog->find($query[0]));
$this->setParams('params', $params);
$this->render();
}
示例2: index
public function index()
{
$Blog = new Blog($this->table_name, $this->action);
$sql = $Blog->find('all');
$blogs = mysqli_query($this->db, $sql) or die(mysqli_error($this->db));
return $blogs;
}
示例3: post
/**
* Add a new post
*
* @param Request $request
* @param string $params
* @return void
*/
protected static function post($request, $params)
{
static::authorize($request);
try {
$data = array('categoryID' => $request->get('categoryID'), 'blogID' => Blog::find(array('id' => $request->user->id))->get('id'), 'title' => $request->get('title'), 'content' => $request->get('content'), 'created' => time());
$post = new Post($data);
static::response($post->save(), 201, '');
} catch (Exception $e) {
static::response(array(), 400, $e->getMessage());
}
}
示例4: update
public function update($id)
{
$blog = Blog::find($id);
if (FEUsersHelper::isCurrentUser($blog->user->id)) {
$blog->title = Input::get('title');
$blog->content = Input::get('content');
$blog->privacy = Input::get('privacy');
$blog->save();
FEEntriesHelper::updatePrivacy($blog->id, 2, $blog->privacy);
return Redirect::back();
} else {
return Redirect::to('/');
}
}
示例5: put
/**
* Update a blog
*
* @param Request $request
* @param string $params
* @return void
*/
protected static function put($request, $params)
{
static::authorize($request);
try {
$blog = Blog::find(array('id' => $params));
if ($blog->userID === $request->user->id) {
$blog->set('name', $request->get('blogname'));
static::response($blog->save(), 200, '');
} else {
static::response(array(), 403, 'No Permission');
}
} catch (Exception $e) {
static::response(array(), 400, $e->getMessage());
}
}
示例6: post
/**
* Log a user in
*
* @param Request $request
* @param string $params
* @return void
*/
protected static function post($request, $params)
{
try {
$user = User::find(array('username' => $request->get('username')));
if (!is_a($user, 'User')) {
static::response(array(), 400, 'No user found');
} elseif (password_verify($request->get('password'), $user->get('password'))) {
$user->blog = Blog::find(array('userID' => $user->id));
static::response($user, 200);
} else {
static::response(array(), 400, 'Wrong password');
}
} catch (Exception $e) {
static::response(array(), 500, $e->getMessage());
}
}
示例7: index
public function index()
{
if (!empty($this->request->data['Admin']['icon'])) {
$this->_saveFavicon();
}
if (!empty($this->request->data['Admin']['export'])) {
$this->SiteExport->_exportSite($this->request->data['Admin']['export']);
}
if (!empty($this->request->data['Upgrade']['all'])) {
$this->SiteUpdate->_runUpdates();
$this->set('runUpdates', true);
}
if (!empty($this->request->data['Update']['index'])) {
$this->view = 'index_upgrade';
}
if (!empty($this->request->data['Alias']['update'])) {
App::uses('Alias', 'Model');
$Alias = new Alias();
$this->set('syncd', $Alias->sync());
$this->view = 'index_upgrade';
}
$complete = $this->Session->read('Updates.complete');
if (!empty($complete)) {
$this->Session->delete('Updates');
$this->Session->setFlash(__('Update check complete!!!'), 'flash_success');
}
$this->set('title_for_layout', 'Admin Dashboard');
$this->set('page_title_for_layout', 'Admin Dashboard');
$this->layout = 'default';
// this is here so we can show "Add Post" links foreach Blog on the dashboard
if (CakePlugin::loaded('Blogs')) {
App::uses('Blog', 'Blogs.Model');
$Blog = new Blog();
$this->set('blogs', $Blog->find('all'));
}
}
示例8: indexAction
public function indexAction()
{
// view all blog posts
$blog = new Blog($this->_db);
$this->_template->posts = $blog->find();
}
示例9: hide_blog
public function hide_blog($id)
{
$blog = Blog::find($id);
$blog->is_published = 0;
$blog->save();
return Redirect::to('/blogs')->with('message', $blog->topic . 'is successfully hidden');
}
示例10: view
public function view($id)
{
// get our post, identified by the route
// parameter
$blog = Blog::find($id);
$blog->views += 1;
$blog->save();
// show the full view, and pass the post
// we just aquired
return View::make('blog.view')->with('blog', $blog);
}
示例11: deleteAction
public function deleteAction()
{
// make sure they own it
$Blog = new Blog($this->_db, new User($this->_db, $_SESSION['user']['id']));
$post = $Blog->find(array('id' => abs($_GET['id'])));
if (empty($post[0]) || $post[0]['users_id'] != $_SESSION['user']['id']) {
$this->_template->hud = array('class' => 'error', 'message' => 'You do not own this post!');
return false;
}
if ($Blog->destroy($_GET['id'])) {
$this->forward('index', array('class' => 'success', 'message' => 'The post was removed!'));
} else {
$this->_template->hud = array('class' => 'error', 'message' => 'There was a problem removing the post!');
}
}
示例12: destroy
/**
* Remove the specified resource from storage.
*
* DELETE /{id}
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$res = Blog::find($id)->delete();
$text = $res ? 'Запись удалена' : 'Запись не удалена';
session()->flash('global', $text);
return redirect('/blog');
}
示例13: mostrarPost
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function mostrarPost($id)
{
$bannersizquierda = Banner::where('seccion', '=', 'BLOG-IZQUIERDA')->where('habilitar', '=', '1')->orderBy('id', 'asc')->get();
$bannersderecha = Banner::where('seccion', '=', 'BLOG-DERECHA')->where('habilitar', '=', '1')->orderBy('id', 'asc')->get();
$bannersindexarriba = Banner::where('seccion', '=', 'INDEX-ARRIBA')->where('habilitar', '=', 1)->orderBy('id', 'asc')->get();
$anuncios = Anuncio::all();
$rolusuarioLogueado = '';
$mailusuarioLogueado = '';
$nombreusuarioLogueado = '';
if (Auth::check()) {
$authuser = Auth::user();
$usu = Usuario::find($authuser->id);
$mailusuarioLogueado = $authuser->email;
$nombreusuarioLogueado = $authuser->nombre;
$rolusuarioLogueado = DB::table('usuario_tiene_rol2')->where('usuario_id', '=', $authuser->id)->first();
$rolusuarioLogueado = UsuarioRol::find($rolusuarioLogueado->rol_id)->rol;
}
$post = Blog::find($id);
return View::make('index.blogPost')->with(array('bannersizquierda' => $bannersizquierda, 'bannersderecha' => $bannersderecha, 'post' => $post, 'anuncios' => $anuncios, 'username' => $mailusuarioLogueado, 'nameuser' => $nombreusuarioLogueado, 'roluser' => $rolusuarioLogueado, 'bannersindexarriba' => $bannersindexarriba));
//
}
示例14: doDelete
/**
* Form for POST doDelete the specified resource.
*
* @return Response
*/
public function doDelete()
{
$aData = Input::all();
if (isset($aData['id'])) {
$blog = Blog::find($aData['id']);
$blog->delete();
return Redirect::route('blog-list')->with('message', 'Блог успешно удален');
}
return Redirect::route('blog-list')->with('message', 'Произошла ошибка удаления');
}