-
Notifications
You must be signed in to change notification settings - Fork 11
entity_guide.md
zuowenjian@ayb edited this page Jun 26, 2016
·
3 revisions
_run.yaml
DB_HOST : "mysql.server"
DB_NAME : "project_${USER}"
DB_USER : "you"
DB_PWD : "password"
class SPU extends XEntity
{
static public function bizCreate($key,$name)
{
$obj = XEntity::createIns(__class__) ;
$obj->ukey = $key ;
$obj->name = $name ;
return $obj;
}
}
class Equipment extends XEntity
{
static public function bizCreate($key,$name)
{
$obj = XEntity::createIns(__class__) ;
$obj->ukey = $key ;
$obj->name = $name ;
return $obj;
}
}
drop table if exists `spu`;
CREATE TABLE `spu` (
id int(11) default null,
ver int(11) default null,
createtime datetime default null,
updatetime datetime default null,
ukey varchar(50) not null ,
name varchar(250) not null ,
PRIMARY KEY (id),
UNIQUE KEY idx_key(ukey)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
drop table if exists `equipment`;
CREATE TABLE `equipment` (
id int(11) default null,
ver int(11) default null,
createtime datetime default null,
updatetime datetime default null,
ukey varchar(50) not null ,
name varchar(255) not null ,
PRIMARY KEY (id),
UNIQUE KEY idx_key(ukey)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
class EntityTest extends PHPUnit_Framework_TestCase
{
public function setUp() {
}
public function testBase()
{
$xas = XAppSession::begin();
Equipment::bizCreate("YITIANJIAN","倚天剑") ;
Equipment::bizCreate("TULONGDAO","屠龙刀") ;
SPU::bizCreate("XUEPING","血瓶");
SPU::bizCreate("MOPING","魔瓶");
$xas->commit();
$obj = XQuery::obj()->list_spu_by_ukey("XUEPING") ;
$xas->commit();
}
}