我正在尝试获取特定时间或时间跨度之间的总行数.基本上,让我们说下表:
CREATE TABLE IF NOT EXISTS `downloads` (
`id` int(7) NOT NULL AUTO_INCREMENT,
`stuff_id` int(7) NOT NULL,
`user_id` int(7) NOT NULL,
`dl_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Run Code Online (Sandbox Code Playgroud)
每次有人下载内容时都会填充此表.
所以我真正需要的是获得一个用户列表(user_id),其在例如24小时的时间段内进行了超过例如100次下载.不是在过去的24小时内,但在那个确切的时间段内,即使去年圣诞节期间=)
有什么想法吗?!
所以,我想说我在我的网站上搜索"古代帝国的故事".我的数据库正在进行全文搜索,结果出现了.我有这个功能的亮点thngy
function sublinhamos($text, $words) {
// explode the phrase in words
$wordsArray = explode(' ', $words);
// loop all searched words
foreach($wordsArray as $word) {
//highlight
$text = str_ireplace($word, "<span class=\"highlight\">".strtoupper($word)."</span>", $text, $count);
}
//right trows results
return $text;
}
Run Code Online (Sandbox Code Playgroud)
这不是太糟糕,但这里的问题是因为搜索术语是"古代帝国的故事",当str_ireplace找到已插入的SPAN时,它会遇到搜索词中的"an"字,并打破SPAN标记.
我需要突出显示突出显示单词的一部分,所有单词最多两个字符,但除了旧的SPAN遇到问题外,它都很好.
有什么想法吗?
所以我需要从一个表中选择不同的值,但是在同一个查询中加入另一个表中的所有相关值.
基本上我遵循Toxi TagSystem架构http://forge.mysql.com/wiki/TagSchema#Toxi
三表之间的多对多映射.
我需要在每一行显示所有插入的值(docs),但是我希望其中一列包含文件用逗号分隔的所有标记.
现在我有
SELECT
docs.id AS id,
docs.orig_file AS orig_file,
docs.date_sent AS date_sent,
tags.tag_name AS alltags
FROM documat AS docs
LEFT JOIN documat_file2tag AS f2t ON f2t.doc_id = docs.id
LEFT JOIN documat_tags AS tags ON tags.id = f2t.tag_id
Run Code Online (Sandbox Code Playgroud)
但是,如果特定的docs.id具有多个标记,则会重复这些行.我希望每行的最终结果是:
| ID | orig_file | date_sent | alltags |
Run Code Online (Sandbox Code Playgroud)
使用所需的结果示例:
| X | example_value.pdf | 2012-03-23 10:14:05 | tag_ex_1, tag_ex_2, etc |
Run Code Online (Sandbox Code Playgroud) 我需要mvFinishItUp()在满足两个条件时执行特定的功能.更具体地说,一个条件是另一个条件的回调成功$.ajax是代码的正常流程,直到它到达函数.有点这样:
$.ajax({
url: mv_finalUrl,
success: function (data) {
mvFinishItUp(data);
},
dataType: 'html'
});
/* here a lot more code, with animations and some delays */
mvFinishItUp(data) {
/* My function code */
/* But this code must only run after it has been called via the call back
and after all the other code has been ran as well */
}
Run Code Online (Sandbox Code Playgroud)
因此,如果ajax回调更快,或者相反,函数必须等待所有代码.有关如何实施这一点的任何想法?
我愿意改变脚本代码的整个概念,因为我相信ajax和函数本身之间的松散代码应该转到函数中...