本文整理汇总了PHP中DataModel::defineEntityModel方法的典型用法代码示例。如果您正苦于以下问题:PHP DataModel::defineEntityModel方法的具体用法?PHP DataModel::defineEntityModel怎么用?PHP DataModel::defineEntityModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataModel
的用法示例。
在下文中一共展示了DataModel::defineEntityModel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DataModel
<?php
require_once "datamodel.class.php";
require_once "database.inc.php";
$_MODEL = new DataModel($_MYSQLI);
$_MODEL->defineEntityModel("user", array("user_id" => DataModel::Type("PrimaryKey"), "user_firstname" => DataModel::Type("NotEmptyString"), "user_lastname" => DataModel::Type("NotEmptyString"), "user_email" => DataModel::Type("Email"), "user_password" => DataModel::Type("NotEmptyString"), "user_address" => DataModel::Type("NotEmptyString"), "user_phone" => DataModel::Type("Phone"), "user_rank" => DataModel::Type("Rank")), "users");
$_MODEL->defineEntityModel("object", array("object_id" => DataModel::Type("PrimaryKey"), "object_name" => DataModel::Type("NotEmptyString"), "object_description" => DataModel::Type("NotEmptyString"), "object_picture_url" => DataModel::Type("NotEmptyString"), "object_minimal_price" => DataModel::Type("UnsignedFloat"), "object_seller_user_id" => DataModel::Type("ForeignKey"), "object_start_date" => DataModel::Type("Timestamp"), "object_end_date" => DataModel::Type("Timestamp"), "object_statut" => DataModel::Type("UnsignedInt")), "objects");
$_MODEL->defineEntityModel("bid", array("bid_id" => DataModel::Type("PrimaryKey"), "bid_object_id" => DataModel::Type("ForeignKey"), "bid_bidder_user_id" => DataModel::Type("ForeignKey"), "bid_price" => DataModel::Type("UnsignedFloat"), "bid_date" => DataModel::Type("Timestamp")), "bids");
/*
$_POST = array("usr" => "chuck", "family" => "noris", "email" => "Carlos@boris.com", "password" => "catonkeyboard", "addr" => "42 rue Internet", "tel" => "0351235139", "rank" => "7");
$result = $_MODEL->createEntity("user", $_POST, array(
"usr" => "user_firstname",
"family" => "user_lastname",
"email" => "user_email",
"password" => "user_password",
"addr" => "user_address",
"tel" => "user_phone",
"rank" => "user_rank"
));
if($result->validEntity) {
// $_MODEL->store($result->entity);
}
else {
print_r($result->errors);
}
$user_entities = $_MODEL->getEntities("user")