1
2
3
4
5
6
7
8
9
10
11
12
13
|
SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for `gl_blog` -- ---------------------------- DROP TABLE IF EXISTS `gl_blog`; CREATE TABLE `gl_blog` ( `id` int (11) NOT NULL auto_increment, ` name ` varchar (200) default NULL , `title` varchar (200) default NULL , `category_id` tinyint(4) default NULL , ` user ` varchar (200) default NULL , PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
1
2
3
4
5
6
7
8
9
10
|
SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for `gl_category` -- ---------------------------- DROP TABLE IF EXISTS `gl_category`; CREATE TABLE `gl_category` ( `id` int (11) NOT NULL auto_increment, `title` varchar (200) default NULL , PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
1
2
3
4
5
6
7
8
9
10
|
SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for `gl_user` -- ---------------------------- DROP TABLE IF EXISTS `gl_user`; CREATE TABLE `gl_user` ( `id` int (11) NOT NULL auto_increment, ` name ` varchar (200) default NULL , PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
1
2
3
4
5
|
class BlogViewModel extends ViewModel { public $viewFields = array ( 'Blog' => array ( 'id' , 'name' , 'title' ), 'Category' => array ( 'title' => 'category_name' , '_on' => 'Blog.category_id=Category.id' ), 'User' => array ( 'name' => 'username' , '_on' => 'Blog.user_id=User.id' ), );} |
1
|
$Model = D( "BlogView" ); $Model ->field( 'id,name,title,category_name,username' )->where( 'id>10' )->order( 'id desc' )->select(); |