当前位置: 首页>>代码示例>>PHP>>正文


PHP DataModel::defineEntityModel方法代码示例

本文整理汇总了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")
开发者ID:benjaminchazelle,项目名称:StarWarsMarket,代码行数:31,代码来源:model.inc.php


注:本文中的DataModel::defineEntityModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。