How to check if a user is edting a table record before allowing another user to edit, not wait for post?
Tag : php , By : Debashree
Date : March 29 2020, 07:55 AM
wish help you to fix your issue There are many system-level approaches you could use to handle the problem. Locking a record for exclusive editing is only one, traditionally chosen by older systems. A more modern methodology is to allow both edits to proceed without locking—termed optimistic concurrency control. If there is an overlapping edit, see if it can be resolved automatically—many simultaneous edits are, in fact, not contentious, especially if they edit unrelated parts of the record.
|
facebook api fql stream, how to check if its page post or user post?
Tag : php , By : Trevor Cortez
Date : March 29 2020, 07:55 AM
will be helpful for those in need You'll need to query the profile table to get this. SELECT id, type FROM profile WHERE id IN (SELECT actor_id FROM #STREAM_QUERY)
|
Mysql select query for getting current user post and followed friend post
Tag : mysql , By : Philofax
Date : March 29 2020, 07:55 AM
To fix this issue First it is recommended to use explicit JOINS over implicit CROSS JOINTry the following query. SELECT
T.postID,
T.message,
T.time,
U.userID,
U.name,
U.username,
U.picture_url,
F.userID2,
FROM
users AS U
INNER JOIN
follow_user AS F
ON U.userID = F.userId1
INNER JOIN
post AS T
ON T.pUserID = U.userID OR T.pUserID = F.userId2
WHERE
U.userID = '$uid' //$uid holds the id of the current logged in user
order by T.postID DESC;
|
How to implement delete of your post and not other user post in Rails
Date : March 29 2020, 07:55 AM
wish helps you Lets say you have a Post model and views all set up: In your views/posts/show you can set up something like this: <% if @post.user.id == current_user.id %>
<%= link_to "Edit", edit_post_path(@post), class:"btn btn-success btn-sm" %>
<% end %>
<% if user_signed_in? %>
<% if @post.user.id == current_user.id %>
<%= render 'form', tutorial: @post %>
<% end %>
<% else %>
<h1>stop trying to edit others post</h1>
<% end %>
|
Date : March 29 2020, 07:55 AM
wish helps you How can i validate if an user belongs to the post he's watching if not dont allow to comment on the post, i tried with if and im using a has_many model like User(devise) UserPost(model) Post and comments(belongs_to post) , playing with the code I tried this and it worked: <%if current_user.courses.exists?(@course.id)%>
do ....
<%end%>
|