field() static public method

Returns a single field value from a table
static public field ( string $table, string $field, mixed $where = null, string $order = null ) : mixed
$table string The table name
$field string The name of the field
$where mixed Either a key/value array as AND connected where clause or a simple MySQL where clause string
$order string Order clause without the order keyword. ie: "added desc"
return mixed
コード例 #1
0
ファイル: a_manage.php プロジェクト: art-youth/framework
 private static function message_model($category, $page = 1, $page_size = 15)
 {
     //处理查询条件
     $condition = null;
     $category_list = array('all' => null, 'unread' => 0, 'read' => 1);
     if (isset($category_list[$category]) && $category_list[$category] !== null) {
         $condition .= 'is_view=' . $category_list[$category];
     }
     //构造SQL语句
     $option['select'] = 'id,is_view,pub_time,user_name,tel,phone,email,message';
     $option['from'] = parent::table;
     $option['where'] = $condition;
     $option['order'] = 'id desc';
     //入库查询
     $rs_count = db::field(parent::table, 'count(1)', $condition);
     $message = db::page_list(sql($option), $rs_count, $page, $page_size);
     //返回结果
     return array('num' => $rs_count, 'info' => $message);
 }
コード例 #2
0
ファイル: m_captcha.php プロジェクト: mjiong/framework
 static function get_send_times($type, $user_id, $cycle = '-4 hours')
 {
     $time = array('egt', date('Y-m-d H:i:s', strtotime($cycle)));
     $condition = compact('user_id', 'type', 'time');
     return db::field(self::TABLE_CAPTCHA, 'count(1)', $condition);
 }