| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx

禅道项目管理(ZenTao)PHP框架提供的DAO功能

0

禅道项目管理软件www.zentao.net)并没有试着去实现ORM或者ActiveRecord这样的概念。因为我们相信,框架要留给开发人员足够的自由发挥的空间,而不是所有的都要包办。所以框架里面提供了一个简单方便的数据库访问对象类:dao,让我们来看具体的写法。

一、查询语句:

$this->dao->select('*')->from('user')->where('account')->eq('wwccss')->fetch();
$this->dao->select('*')->from('user')->where('id')->gt(10)->andWhere('age')->lt(20)->orderBy('id desc')->limit('1,10')->fetchAll()

条件语句:

$this->dao->select('*')->from('user')->where('id')->gt(10)->beginIF($class == 'online')->andWhere('status')->eq('online')->fi()->fetchAll();

二、插入语句:

$user->account = 'wwccss';
$user->password = '123456';

$this->dao->insert('user')->data($user)->exec();
return $this->dao->lastInsertID();

或者:

$this->dao->insert('user')

  ->set('account')->eq($account)
  ->set('password')->eq($password)
  ->exec();

三、更新语句:

$this->dao->update('user')->data($user)->where('id')->eq($userid)->limit(1); 或者:

$this->dao->update('user')

  ->set('account')->eq($account)
  ->set('password')->eq($password)
  ->exec()

四、REPLACE语句

$this->dao->replace('user')->data($user)->exec();  

五、删除语句:

$this->dao->delete()->from('user')->where('id')->eq($userid);

六、左连接

$this->dao->select('t1.*, t2.*')->from('user')->alias('t1')->leftJoin('userGroup')->alias('t2')->on('t1.account = t2.account')->fetchAll();

六、其他便利的方法:

$this->dao->findByAccount($account)->from('user')->fetch(); // 魔术方法,按照account进行查询。
$this->dao->select('*')->from('user')->fetchAll('account');     // 返回的结果中,以account为key。
$this->dao->select('account, realname')->from('user')->fetchPairs();     // 返回account=>realname的键值对。
$this->dao->select('class, account, realname')->from('user')->fetchGroup('class');     // 按照所属的class进行分组。

7个答案

0

ดาวน์โหลดjoker123 auto Online slots, mobile phones, new online slots games, online slots that are the hottest in 2020, with low capital, can play.

0

ทางเข้า joker123 Top camp slots games Genuine license from PGSLOT game camp, online slots, direct web slot game service.

0

joker PG SLOT Game is a new and hot slot game that is gaining popularity right now, online slots, direct websites, not through agents.

0

เว็บตรง สล็อต PG SLOT online slots games A game that is popular with players all over the world right now. Your slots play will never be boring again.

0

24 hours a day for using the service with us. online gambling website ufabet I've told a lot of people. that having enough to eat now part of it came from Football betting is a career supplement from a regular job. แทงบอลมือถือ ได้เงินจริง

0

A very excellent blog post. I am thankful for your blog post. I have found a lot of approaches after visiting your post. Goldshell lt5 pro for sale

0