首页
开发手册
应用中心
工具
用户中心
DBO Application: Query Data
English
中文简体
English
上一篇
下一篇
### DBO Application: Query Data DBO is based on an array, and performs database query operations through the setting of different parameters. Data query is a common way of using databases. Generally, programs need to query multiple data or only one data. DBO integrates multiple queries and a single query to provide developers with learning convenience. #### Use sql_select() to query data - Single Query ```php $table['a'],'where'=>"id=1")); //②Use the sql_join() method to perform associative query $data_info = sql_select(array('sql'=>sql_join(),'where'=>"id=1")); //close the database $db->close(); ?> ``` - Multiple Queries ```php 'sql' //define the data table $table['a'] = 'admin_user';//administrator table $table['b'] = 'admin_group';//administrator group table $ljoin['b'] = 'b.id=a.gid';//associated conditions $t_field = 'a.id,a.nickanme,b.group_name';//query field //①Single table query $sql = sql_select(array('table'=>$table['a'],'where'=>"id in (1,2,3)",'order'=>'id DESC','type'=>"sql")); //②Use the sql_join() method to perform associative query $sql = sql_select(array('sql'=>sql_join(),'where'=>"id in (1,2,3)",'order'=>'id DESC','type'=>"sql")); //execute database statement $query = $db->query($sql); //loop query as an array while($dls = $db->fetch_array($query)){ $list[] = $dls; } //close the database $db->close(); ?> ``` - Data Paging ```php $table['a'],'where'=>"id in (1,2,3)",'order'=>'id DESC','type'=>"sql")); //②Use the sql_join() method to perform associative query $sql = sql_select(array('sql'=>sql_join(),'where'=>"id in (1,2,3)",'order'=>'id DESC','type'=>"sql")); //execute database statement $data_info = limit($sql,10);//execute sql statement, 10 pieces of data are 1 page $pages = pages($data_info['info']);//Output page number //close the database $db->close(); ?> ``` - Total Number of Query Data ```php 'num' to query the total number of data $nums = sql_select(array('table'=>"user",'where'=>"username='FOUNDPHP'",'type'=>'num')); //close the database $db->close(); >? ```