ORDER BY DESC LIMIT包含超过1000个条目的数据库 [英] ORDER BY DESC LIMIT with database containing over 1000 entries
本文介绍了ORDER BY DESC LIMIT包含超过1000个条目的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一切都运转良好,然后我不断得到999作为最后一个值。我假设它看到9大于1000中的1。我可能错了。但是它不会返回超过1000的任何内容。代码发布在下面。任何帮助都会很棒。
$ db = new PDO(' mysql:host ='。< span class =code-sdkkeyword> $ host 。' ; dbname ='。 $ db_name,$ db_username,$ db_password);
$ statement = $ db-> prepare( select * from user where user_name =:user_name);
$ statement-> execute(array(' :user_name' => $ user )); // 更改发送到变量
$ row = $ statement-> fetch();
// //////////////// ////////////////////////////////////////////////// ///////////////////////////////////////
$ db2 = new PDO(' mysql:host ='。 $ host 。' ; dbname ='。$ db_name_uroll,$ db_username,$ db_password);
// 删除$ db2 prepare
$ statement2 = select * from`{$ user}`ORDER BY bet_id DESC LIMIT 23;
$ bid = array();
if ($ stmt = $ db2-> query($ statement2)) // PDO :: query()在成功时返回PDOStatement,在失败时返回false。
{
// 如果我们从PDO :: Query()获得PDOStatement作为返回值!!! ECHO WHILE FETCHING !!!
while($ row2 = $ stmt-> fetch(PDO :: FETCH_ASSOC)) // 这个循环将继续与PDOStatement返回的行数一样多。
{
$ bid [] = $ row2 [' bet_id'];
}
}
解决方案
db = new PDO(' mysql:host ='。
host 。' ; DBNAME ='跨度>
DB_NAME,
Everything was working fine, then I kept getting 999 as the last value. I'm assuming that it sees that the 9 is bigger than the 1 in 1000. I may be wrong though. However it will not return anything over 1000. The code is posted below. Any help would be great.
$db = new PDO('mysql:host='. $host .';dbname='.$db_name, $db_username, $db_password);
$statement = $db->prepare("select * from users where user_name = :user_name");
$statement->execute(array(':user_name' => $user)); //change send to variable
$row = $statement->fetch();
///////////////////////////////////////////////////////////////////////////////////////////////////////////
$db2 = new PDO('mysql:host='. $host .';dbname='.$db_name_uroll, $db_username, $db_password);
//Remove $db2 prepare
$statement2 = "select * from `{$user}` ORDER BY bet_id DESC LIMIT 23";
$bid = array();
if ($stmt = $db2->query($statement2)) //PDO::query() returns a PDOStatement on success or false on failure.
{
//If we got a PDOStatement as a return value from PDO::Query() !!!ECHO WHILE FETCHING!!!
while($row2 = $stmt->fetch(PDO::FETCH_ASSOC)) //This loop will keep going for as many rows as the PDOStatement returns.
{
$bid[] = $row2['bet_id'] ;
}
}
解决方案
db = new PDO('mysql:host='.
host .';dbname='.
db_name,
这篇关于ORDER BY DESC LIMIT包含超过1000个条目的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文