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

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

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的資料庫是在哪,thinkphp的資料庫是在哪?

這個你要先建一個資料庫,然後在config.php檔案或者直接在thinkphp資料夾下面的配置檔案那裡填寫好資料庫的名字,地址賬號密碼等然後才可以用的。然後在控制器那裡進行操作就行了。這裡因為你還沒有建表所以要執行 model m sql create table if not exists th...

在oracle資料庫中如果查詢資料庫中有哪幾張表

分兩種情況,一種是查詢當前使用者下的表,另一種是查詢當前資料庫下所有的表。查詢當前使用者的表 select table name from user tables 查詢當前資料庫下所有的表 select from user tables 查詢當前使用者的表 select from all table...

sql怎樣跨資料庫查詢,sql怎樣跨資料庫查詢oracle

使用dblink。例如 當前使用的資料庫是orcl1 要查詢的資料庫是orcl2的scott使用者的表。create public database link orcl2 scott connect to scott identified by tiger using description add...