0

I want to execute this SQL query:

SELECT * FROM  `wcf1_user` WHERE  `lastActivityTime` < 1343642175

But I receive this error:

#1054 - Unknown column '1343642175' in 'where clause'

But this makes absolutely no sense. 1343642175 isn't my column, lastActivityTime is it.

I tried it in phpMyAdmin like this: phpmyadmin

enter image description here

The error is the same.

Any ideas?

Here is my full code:

$date = strtotime("-1 month");
$db = & JDatabase::getInstance( $option );
$query = $db->getQuery(true);
$query ->select('userID, username, email, lastActivityTime')
       ->from('wcf1_user')
       ->where('lastActivityTime < '.(int) $date);
$db->setQuery($query);
$result=$db->loadObjectList();

Note: that this is made inside a joomla component

EDIT:

Now it works fine, I haven't done anything to my code. I just restarted my Computer. I don't know what caused this error, but now it's gone.

4

3 回答 3

0

您的查询运行良好,也许您提供的代码不完整。

在这里看演示

编辑。

   $date=strtotime("-1 month");
   $db = & JDatabase::getInstance( $option );
   $query = $db->getQuery(true); 
   $query ->select('userID, username, email, lastActivityTime');
   $query->from('wcf1_user');
   $query->where('lastActivityTime < '.(int) $date); 
   $db->setQuery($query);
   $result=$db->loadObjectList();
于 2013-01-30T11:38:33.727 回答
0

您使用的数字不是数字。它包含奇怪的字符。尝试手动输入数字。

于 2013-01-30T11:24:34.907 回答
0

尝试使用以下内容:

$date = strtotime("-1 month");
$db = JDatabase::getDBO();
$query = $db->getQuery(true);
$query ->select('userID, username, email, lastActivityTime')
       ->from('#__user')
       ->where('lastActivityTime < '.(int) $date);
$db->setQuery($query);
$result=$db->loadObjectList();

使用 Joomla,表格有一个全局前缀,即#__

希望这可以帮助

于 2013-01-30T12:23:20.980 回答