/获取数据
$a_hufu = DB::LimitQuery('brand',
array(
array('select'=>'id,name'),
'condition'=>array('type'=>'hufu'),
)
);
参数1 是表名称
参数2 是个数组 select 是要筛选的字段 默认为*
condition 是Sql语句的条件
// $condition['OR'] 或
if (!option_yes('displayfailure')) {
$condition['OR'] = array(
"now_number >= min_number",
"end_time > '{$daytime}'",
);
}
具体可以查看函数原型:\include\library\DB.class.php
//根据条件条件统计表中的条数
$count = Table::Count('team', $condition);
//分页
list($pagesize, $offset, $pagestring) = pagestring($count, 10);
include\template 模板目录
team 团商品
//首页调用团
include\function\common.php index_get_team($city_id) 获取某个城市下的团购商品 首页显示
//增加菜单
include\模板目录\block_navigator.html
include\compiled\block_navigator.php 修改两项
1:如何取得最土数据库中一条数据。使用LimitQuery()
$res = DB::LimitQuery('subscribe',array('condition'=>array('email'=>$email),'one'=>true));
2:最土程序如何进行数据库插入数据
$table = new Table('subscribe', array(
'email' => $email,
'city_id' => $city_id,
'secret' => $secret,
));
return $table->insert(array('email', 'city_id', 'secret'));
3:检索一行内容
$field = strpos($email, ) ? 'email' : 'username';
$zuituuser = DB::GetTableRow('user', array(
$field => $email,
'password' => $password,
));
4:通过某个值检索一行数据
return Table::Fetch('user', $email, 'email');
5:修改数据库字段某个值
$table = new Table('user', $newuser);
$table->SetPk('id', $user_id);
if ($table->password) {
$plainpass = $table->password;
$table->password = self::GenPassword($table->password);
}
return $table->Update( array_keys($newuser) );
6:如何统计数据库中某些数据的条数
$now_count = Table::Count('order', array(
'user_id' => $login_user_id,
'team_id' => $id,
'state' => 'pay',
), 'quantity');
7:如何修改数据库中某个字段的值
Table::UpdateCache('order',$table->id,array('order_sn'=>get_order_sn()));
8:最土中如何检索某个字段的值
$cond = array('zone'=>'city');$info = DB::LimitQuery('category', array(
'condition' => $cond,
'order' => 'ORDER BY id DESC',
));
$citys = Utility::GetColumn($info, 'name