Skip to content
zuowenjian@ayb edited this page Jun 22, 2016 · 1 revision

#数据访问

实体 XEntity

class User extends XEntity
{
    static public function createByBiz($name,$passwd)
    {
        $obj = XEntity::createIns(__CLASS__);
        $obj->logname = $name;
        $obj->name    = $name;
        $obj->passwd  = $passwd;
        return $obj ;
    }
}

##实体映射规则

  • 数据库的表名与实体属性名一致;
  • 不区分大小写(表全为小写)
  • 实体中对象与对象1对1的关系:在表中使用classname__id的方式表示关联的对象

数据读取

XQuery

XQuery::obj()->get_Author_by_id("1000");
XQuery::arr()->get_Author_by_id("1000");

XWriter

数据页

$pageno = 1 ;
$page = new DataPage(20); 
$page->gotoPage($pageno);
$books = XQuery::obj()->list_book($page); 

复杂查询

//列出加个大于10小于10.5的书籍
$books  = XQuery::obj()->list_Book_by_price(QL('? > 10 and ? < 10.5 ')); 
//列出书名以c开头的书籍
$books2 = XQuery::obj()->list_Book_by_name(QL('? like "c%"')); 
//列出书名以c开头并价格小于100的书
$books3 = XQuery::obj()->list_Book_by_name_price(QL('? like "c%"'),QL('? < 100'));
Clone this wiki locally