简体   繁体   English

mysql搜索查询和使用php或javascript的分页

[英]mysql search queries and pagination with php or javascript

Im developing a site where its users can search for other users on the same website. 我正在开发一个网站,其用户可以在同一网站上搜索其他用户。

The queries can be very long and complex, so i would like to save some of the work done, so i dont have to repeat the same work again. 查询可能会很长而且很复杂,所以我想保存一些完成的工作,因此我不必再次重复相同的工作。

I was thinking i could save the results in a table, so when i use pagination it woudnt have to do the same query all over again, it could just get the results from the result table. 我当时想我可以将结果保存在一个表中,所以当我使用分页时,不必再次进行相同的查询,它只能从结果表中获取结果。 How does this sound? 听起来如何?

Maybe there is another better way? 也许还有另一种更好的方法? Is it possible to save queries in php sessions? 是否可以在php会话中保存查询? Is this a good idea? 这是一个好主意吗? Also im not sure what kind of pagination i should make, the one that goes like , prev , 1 , 2, 3 ,4 , next, or the "facebook style" where u just add 20 more results to the page every time scroller hits 10% of bottom window. 另外,我不确定我应该进行哪种分页,如prev,prev,1,2,3,4,next或“ facebook样式”,每次滚动条命中时,您只会向页面添加20个结果底部窗口的10%。

Any thoughts on the matter? 有什么想法吗? :)) :))

Best of regards, Alexander 最好的问候,亚历山大

Would all users be submitting similar queries? 所有用户都将提交类似的查询吗? If so, you may want to look into caching, such as memcached . 如果是这样,您可能需要研究诸如memcached之类的缓存

As for the pagination, if you want users to see the next X results automatically, somewhat like what's described here . 至于分页,如果您希望用户自动查看下一个X结果,就像这里描述的那样。

Just optimize your search query (if needed). 只需优化您的搜索查询(如果需要)。
In fact, database intended to "to repeat the same work again". 实际上,数据库旨在“再次重复相同的工作”。 Nothing wrong with it. 没错。

No need to output results to a table. 无需将结果输出到表。 If you're really concerned, index and even do stored procedures, but it's likely not necessary. 如果您真的很在意,甚至对存储过程建立索引,但这可能不是必需的。

I like building an Ajax query with DataTables , then using their Pipeline feature to grab a few sets of results ahead of and behind the data that the user has actually requested--based on filter, pagination, and sorting variables that are pre built-in to the front-end code. 我喜欢使用DataTables构建一个Ajax查询,然后使用其Pipeline功能在用户实际请求的数据之前和之后获取几组结果-基于预先内置的过滤器,分页和排序变量前端代码。 Because you're spreading out the queries, it appears to the user that it's not taking any time at all to do. 因为您正在散布查询,所以对用户来说似乎根本不需要花费任何时间。 I have it running on tables of several hundred thousand results very effectively. 我非常有效地在数十万个结果的表上运行它。 And, it's VERY easy to do. 而且,这非常容易做到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM