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

2021-07-05 18:12:28 字數 1658 閱讀 8036

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 查出一張表的所有資料的方法,希望能夠幫到您。

資料庫查詢,資料庫查詢語句

try this,should be fine select sn,result,ttimefrom select sn,result,ttimefrom tab t1 where not exists select 1 from tab where sn t1.sn and ttime t1.tt...

資料庫查詢問題

你使用for迴圈對dw 1進行迴圈,因為dw 1資料是全的。然後對應使用find函式,來查詢dw 2中地區對應的行,如果有行,說明是有對應值,取該行相關值,放入dw 1.如果沒有,那麼就是你說少一行的情況了,dw 3設0.比如地區欄位叫area code long row,ll find,ll ne...

informix資料庫如何建立資料庫,建立資料庫表,建立索引

為t kc表的cname欄位建立索引。最後當然主鍵當然是sid了 一定要標好哦 informix第乙個真正支援sql語言的關聯式資料庫產品是informix se standardengine 1 有輸入輸出 create procedure pnormalparam f1 integer,f2 v...