我想看看数据库中有多少数组。它非常慢,我想知道是否有一种方法可以在没有 for 循环的情况下搜索多个单词或整个数组。我现在挣扎了一段时间。
这是我的代码
$dateBegin = "2010-12-07 15:54:24.0";
$dateEnd = "2010-12-30 18:19:52.0";
$textPerson = " text text text text text text text text text text text text text text ";
$textPersonExplode = explode(" ", $textPerson );
$db = dbConnect();
for ( $counter = 0;$counter <= sizeof($textPersonExplode)-1 ; $counter++) {
$query = "SELECT count(word) FROM `news_google_split` WHERE `word` LIKE '$textPersonExplode[$counter]' AND `date` >= '$dateBegin' AND `date` <= '$dateEnd'";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$word[] = $textPersonExplode[$counter];
$count[] = $row[0];
}
if (!$result) {
die('Invalid query: ' . mysql_error());
}
}
谢谢您的帮助。