thinkphp如何查詢資料庫某一表中有多少條資料

時間 2021-07-05 18:12:34

1樓:每天搜網路科技

其實我感覺你這個邏輯沒問題,**有點問題,我是這麼認為的,**應該是這樣

$idzhi = rand(0,表中資料條數);

$data = $data['id']; // 我不明白你這裡是什麼意思

$arr = $m->where($data >= $idzhi)->limit(8) ->select();

不過我總感覺上面的有問題

$idzhi = rand(0,表中資料條數);

$arr = $m->where("id >= $idzhi")->limit(8) ->select();

不對的話就試試這個,我個人覺得這樣是對的,不明白你那個$data['id'];是幹嘛用的

2樓:

$arr = $m->where($data)->count();

求助:在php中,怎麼才能知道資料庫(mysql)的表裡面一共有多少條記錄啊? 20

3樓:匿名使用者

如果是客戶端連線資料庫的話,一條語句ok。select count(*) from tablename;

<?php

$conn=mysql_connect('localhost','root','password');//連線資料庫

mysql_select_db('databasename',$conn);//選擇要查詢的資料庫

$sql="select count(*) from tablename";//sql查詢語句

if($result=mysql_query($sql,$conn))

4樓:逃離

<?php

$sql = "select count(*) from 表名";

$result = mysql_query($sql);

if ($result)

list($count) = mysql_fetch_row($result);

echo $count;

?>

thinkphp 怎麼查出一個資料庫的表的所有資料

5樓:承凝冬

$goods = d('goods');//例項化model物件,實際操作goods資料表

$info = $goods -> select();//獲得資料資訊

print_r($info);//列印資訊

6樓:相逢港

如果要用thinkphp查詢出一張表的所有資料,可以這樣來做:

假設資料表的表名為:think_table1,這裡think_ 是表字首(包含下滑線)。

thinkphp內建了m函式,可以這樣例項化think_table1這張表: m('table1') , 因為think_這個字首名稱在配置檔案中定義過,所以,m()函式中只寫“table1”即可。可以省略表字首think_

取出think_table1這張表的全部資料:

$result = m('table1')->select();

在這裡,$result 中存放的,就是 think_table1 這張表的全部資料。

以上就是:thinkphp 查出一張表的所有資料的方法,希望能夠幫到您。

thinkphp查詢資料庫後如何撒資料

我給你舉個例子吧 按照你上面舉得例子 use think controller class logincontroller extends controller thinkphp怎麼獲取資料庫資料 我給你舉個例子吧 按照你上面舉得例子 use think controller class login...

C資料庫查詢

有兩種方法 1 建立3個靜態欄位,在登入窗體驗證通過時為這3個欄位賦值,以後其他窗體 資訊管理視窗 再呼叫這賦值後的3個靜態欄位就行了。2 在登入窗體設定3個公有變數,以後其他窗體 資訊管理視窗 再呼叫登入窗體3個公有變數就可以了。你說的 可以在登入視窗那裡用session username tex...

資料庫查詢問題

試試這個 sql select owner1.class1.name,owner1.class1.pwd from owner1.class1 union select owner2.class2.name,owner2.class2.pwd from owner2.class2 owner1 是表...