php - How to better implement Like/Unlike System using mysql -
I am developing a uniform / contrast system using jquery, php, and mysql for my wordpress multizite. Basically, sub-sites contain posts and products, where users can like them and can not contrast them. My plan is to store the choice in a global table so that I use it to display the number of posts and likes for the main site and to use the most preferred posts / products and a different page for some type Can do
In my mysql table naming, global_nank
I have these columns.
like_id | User_id | Blog_id | Object_id | Object_type | Date_added
The example would be:
like_id | User_id | Blog_id | Object_id | Object_type | Date_added 1 | 24 | 81 403 | Posted in | 2014-01-22 05:55:23 2 36. 29 | 108 | Products | 2013-02-26 12:23:10
In my jquery I use it as part:
jQuery.ajax ({url : '/ Wp -content / plugins / plugname / like.php', type: 'post', data: {object_id: object_id, user_id: user_id, type: 'like', blog_id: blog_id, object type: object_type, count: Default_count}, data type: 'json', success: function (data) {var new_count = parseInt (default_count) + 1; jQuery ('# like_click_' + object_id) .attr ('Data-like-count', new_count); JQuery ('# like_click_' + Object_id) .attr ('id', '#unlike_click_' + object_id); isProcessing = false;}});
On my server side, I use PHP as part of this, which includes datas after some type of validation:
$ Wpdb- & gt; Insert $ $ global_likes, array ('user_id' = & gt; $ user_id, 'blog_id' = & gt; $ blog_id, 'object_id' = & gt; $ object_id, 'object_type' => $ item_type, 'date_added' = & Gt; $ date_added)); This is the problem now, the problem is that many rows are expected as different blogs prefer different choices given by different users on different posts / products. has gone. Like it is like thousands or millions Is this an overkill ?? Or the reason for the heavy load could be because I currently use 512 MB application RAM. I'm very worried about performance and CPU use. Considering that different blogs are preferred on each post / product and also it is displayed on the main site, which displays all posts along with the number of likes along with all the blogs. In addition, users can also like / unselect a post from the main site.
Example: When displaying a post or product on a specific blog or main site,
- The number of likes is being examined and displayed.
- Check if the user did not like the post by checking
user_id
on the global table. - User can not like / liked a post / product.
On the main profile also on the user profile page.
- Inquiries to check the global choice table
- The number of items liked by the network.
Am I using the right and the best way to implement it or is there a better way for me to know only php, jquery and mysql if you are thinking like Nosql
or similar, it probably will not help me because I am using WordPress and I do not know how.
Comments
Post a Comment