当前位置: 首页>>代码示例>>PHP>>正文


PHP Db::selectOne方法代码示例

本文整理汇总了PHP中Db::selectOne方法的典型用法代码示例。如果您正苦于以下问题:PHP Db::selectOne方法的具体用法?PHP Db::selectOne怎么用?PHP Db::selectOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Db的用法示例。


在下文中一共展示了Db::selectOne方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getById

 public static function getById($id)
 {
     $result = Db::selectOne('SELECT * FROM ' . self::getDbTable() . ' WHERE id = :id', array('id' => $id));
     if (empty($result)) {
         return null;
     }
     $class = get_called_class();
     return new $class($result);
 }
开发者ID:vincenthib,项目名称:visiteztokyo,代码行数:9,代码来源:Model.class.php

示例2: get

 public static function get($sql, $vars = array())
 {
     $class = self::getClass();
     $result = Db::selectOne($sql, $vars);
     if (empty($result)) {
         return null;
     }
     return new $class($result);
 }
开发者ID:NikosAnderson,项目名称:shop,代码行数:9,代码来源:Model.class.php

示例3: getRandom

 public static function getRandom()
 {
     return new Quarter(Db::selectOne('SELECT * FROM quarter ORDER BY RAND() LIMIT 1'));
 }
开发者ID:vincenthib,项目名称:visiteztokyo,代码行数:4,代码来源:Quarter.class.php

示例4: getFacebookUser

 public function getFacebookUser($register_url)
 {
     $fb_user = API_Facebook::getUser($register_url);
     if (empty($fb_user) || !is_object($fb_user)) {
         return false;
     }
     foreach ($this->getFields() as $key => $value) {
         if (property_exists($fb_user, $key)) {
             $this->{$key} = $fb_user->{$key};
         }
     }
     // @FIXME
     $this->password = password_hash($this->fb_id . '-' . $this->email, PASSWORD_BCRYPT);
     $fb_user = Db::selectOne('SELECT * FROM user WHERE fb_id = :fb_id', array('fb_id' => $this->fb_id));
     if (!empty($fb_user)) {
         $user = new User($fb_user);
         return $user->login();
     }
     $this->id = $this->facebookRegister();
     if (!empty($this->id)) {
         return $this->login();
     }
 }
开发者ID:vincenthib,项目名称:visiteztokyo,代码行数:23,代码来源:User.class.php

示例5: getPicture

 public function getPicture()
 {
     $result = Db::selectOne('SELECT src FROM photo WHERE info_id = :info_id', array('info_id' => $this->id));
     if (empty($result)) {
         $picture = new Picture();
         $picture->src = 'http://placehold.it/60x60';
         return $picture;
     }
     return new Picture($result);
 }
开发者ID:vincenthib,项目名称:visiteztokyo,代码行数:10,代码来源:Info.class.php

示例6: array

         $files[$quarter_id] = array();
     }
     $find_type = false;
     foreach ($types as $type_name => $type_id) {
         if (strpos($value, $type_name) !== false) {
             $find_type = true;
             if (empty($files[$quarter_id][$type_id])) {
                 $files[$quarter_id][$type_id] = array();
             }
             $sub_folder = trim(str_replace($folder . '/' . $quarter_name . '/' . $type_name, '', $value), '/');
             $sub_folder = ucwords(Utils::cleanString(dirname($sub_folder), ' '));
             if (empty($sub_folder)) {
                 $files[$quarter_id][$type_id][0][] = $value;
                 continue;
             }
             $info = Db::selectOne('SELECT id, name FROM info WHERE name LIKE :name', array('name' => '%' . $sub_folder . '%'));
             if (!empty($info)) {
                 //echo $sub_folder.' => '.print_r($info['id'], true).'<br>';
                 if (empty($files[$quarter_id][$type_id][$info['id']])) {
                     $files[$quarter_id][$type_id][$info['id']] = array();
                 }
                 $files[$quarter_id][$type_id][$info['id']][] = $value;
             } else {
                 $errors[] = $sub_folder;
             }
         }
     }
     if (!$find_type) {
         $files[$quarter_id][0][] = $value;
     }
 }
开发者ID:vincenthib,项目名称:visiteztokyo,代码行数:31,代码来源:moulinette.php

示例7: setPresence

 public function setPresence($day = null)
 {
     if (is_null($day)) {
         $day = date('Y-m-d');
     }
     $this->presence = new Presence(Db::selectOne('SELECT * FROM presence WHERE student_id = :student_id AND day = :day', array('student_id' => $this->id, 'day' => $day)));
 }
开发者ID:erichub,项目名称:-Dashboard-Process,代码行数:7,代码来源:Student.class.php

示例8: selectOne

 public static function selectOne($sql, $bindings = array())
 {
     $entity = get_called_class();
     return new $entity(Db::selectOne($sql, $bindings));
 }
开发者ID:vincenthib,项目名称:cooking,代码行数:5,代码来源:Model.class.php

示例9: presence

 public function presence()
 {
     $id = $this->getParam(0, 0);
     $presences = array(array('Type', 'Count'), array('R1', 0), array('R2', 0), array('D1', 0), array('D2', 0), array('Absent', 0));
     if (!empty($id)) {
         $student_presence = Db::selectOne('SELECT SUM(r1) as R1, SUM(r2) as R2, SUM(d1) as D1, SUM(d2) as D2, SUM(absent) as Absent FROM presence GROUP BY student_id HAVING student_id = :student_id', array('student_id' => $id));
         if (!empty($student_presence)) {
             $presences = array(array('Type', 'Count'), array('R1', !empty($student_presence['R1']) ? (int) $student_presence['R1'] : 0), array('R2', !empty($student_presence['R2']) ? (int) $student_presence['R2'] : 0), array('D1', !empty($student_presence['D1']) ? (int) $student_presence['D1'] : 0), array('D2', !empty($student_presence['D2']) ? (int) $student_presence['D2'] : 0), array('Absent', !empty($student_presence['Absent']) ? (int) $student_presence['Absent'] : 0));
         }
     }
     $this->response->addVar('presences_data', json_encode($presences));
     return $this->base_list('presence', array('student_id', 'day', 'r1', 'r2', 'd1', 'd2', 'absent', 'motif'));
 }
开发者ID:erichub,项目名称:-Dashboard-Process,代码行数:13,代码来源:AdminController.class.php

示例10: array

<?php

require_once 'config/config.conf.php';
try {
    $articles = Db::selectAll('SELECT * FROM posts LIMIT 5');
    echo Utils::debug($articles);
    echo '<hr>';
    $article = Db::selectOne('SELECT * FROM posts WHERE id = :id', array(':id' => 23));
    echo Utils::debug($article);
} catch (Exception $e) {
    echo $e->getMessage();
}
开发者ID:raphamim,项目名称:POO,代码行数:12,代码来源:index.php


注:本文中的Db::selectOne方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。