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


PHP Get::db方法代码示例

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


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

示例1: for_query

 static function for_query($query)
 {
     $db = Get::db('songwork');
     $res = array();
     $db->query($query);
     while ($x = $db->next_record()) {
         $res[$x['id']] = new Consultation($x);
     }
     return $res;
 }
开发者ID:songwork,项目名称:songwork,代码行数:10,代码来源:Consultation.php

示例2: popular

 static function popular()
 {
     $db = Get::db('songwork');
     $res = array();
     $db->query("SELECT id, name, COUNT(*) FROM documents_tags LEFT JOIN tags ON documents_tags.tag_id=tags.id GROUP BY id, name ORDER BY COUNT(*) DESC");
     while ($x = $db->next_record()) {
         $res[$x['id']] = new Tag($x);
     }
     return $res;
 }
开发者ID:songwork,项目名称:songwork,代码行数:10,代码来源:Tag.php

示例3: get_by_person

 static function get_by_person($p)
 {
     if (!is_a($p, 'Person') || intval($p->id) == 0) {
         return false;
     }
     $db = Get::db('songwork');
     $db->query("SELECT * FROM admins WHERE person_id=" . $p->id);
     if ($db->num_rows() == 0) {
         return false;
     }
     $x = new Administrator($db->next_record());
     $x->set_person($p);
     return $x;
 }
开发者ID:songwork,项目名称:songwork,代码行数:14,代码来源:Administrator.php

示例4: __construct

 function __construct($id_or_array)
 {
     $this->db = Get::db($this->dbname);
     if (is_array($id_or_array)) {
         $this->me = $id_or_array;
         $this->id = intval($id_or_array['id']);
     } elseif (is_int($id_or_array) || is_string($id_or_array) && ctype_digit($id_or_array)) {
         $this->id = intval($id_or_array);
         $this->db->query("SELECT * FROM {$this->tablename} WHERE id=" . $this->id);
         if ($this->db->num_rows() == 0) {
             $this->failed = true;
         }
         $this->me = $this->db->next_record();
     }
 }
开发者ID:songwork,项目名称:songwork,代码行数:15,代码来源:SongworkDB.php

示例5: testCookie

 function testCookie()
 {
     $p = new Person(3);
     $p->set_auth();
     # get what the cookie would have been
     $db = Get::db('songwork');
     $db->query("SELECT * FROM logins WHERE person_id=3");
     $x = $db->next_record();
     $cookie_value = $x['cookie_id'] . ':' . $x['cookie_tok'];
     $_COOKIE['ok'] = $cookie_value;
     $p = Person::get_by_cookie();
     $this->assertType('Person', $p);
     $this->assertEquals(3, $p->id);
     $this->assertEquals('Yoko', $p->firstname());
     $_COOKIE['ok'] = $cookie_value . 'x';
     $p = Person::get_by_cookie();
     $this->assertFalse($p);
 }
开发者ID:songwork,项目名称:songwork,代码行数:18,代码来源:testPersons.php

示例6: with_ids

 static function with_ids($array_of_ids)
 {
     # clean incoming array, just in case of bad info
     $real_ids = array();
     foreach ($array_of_ids as $maybe_id) {
         if (is_integer($maybe_id) || is_string($maybe_id) && ctype_digit($maybe_id)) {
             $real_ids[] = intval($maybe_id);
         }
     }
     if (count($real_ids) == 0) {
         return array();
     }
     $db = Get::db('songwork');
     $res = array();
     $db->query("SELECT * FROM persons WHERE id IN (" . join(',', $real_ids) . ")");
     while ($x = $db->next_record()) {
         $res[$x['id']] = new Person($x);
     }
     return $res;
 }
开发者ID:songwork,项目名称:songwork,代码行数:20,代码来源:Person.php

示例7: pulldown_for_currency

 static function pulldown_for_currency($currency)
 {
     if (!Currency::is_valid($currency)) {
         return false;
     }
     $res = array();
     $db = Get::db('songwork');
     $db->query("SELECT code, millicents FROM pricerefs WHERE currency='{$currency}' ORDER BY millicents ASC");
     while ($x = $db->next_record()) {
         $m = new Money($x['millicents'], $currency);
         $res[$x['code']] = $m->show_with_code();
     }
     return $res;
 }
开发者ID:songwork,项目名称:songwork,代码行数:14,代码来源:PriceRef.php

示例8: consultable

 static function consultable()
 {
     $db = Get::db('songwork');
     $res = array();
     $db->query("SELECT * FROM teachers WHERE available='t' ORDER BY id ASC");
     while ($x = $db->next_record()) {
         $res[$x['id']] = new Teacher($x);
     }
     return $res;
 }
开发者ID:songwork,项目名称:songwork,代码行数:10,代码来源:Teacher.php

示例9: all

 static function all()
 {
     $db = Get::db('songwork');
     $res = array();
     $db->query("SELECT * FROM students ORDER BY id DESC");
     while ($x = $db->next_record()) {
         $res[$x['id']] = new Student($x);
     }
     return $res;
 }
开发者ID:songwork,项目名称:songwork,代码行数:10,代码来源:Student.php


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