本文整理汇总了PHP中Entity::isObjectEntity方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::isObjectEntity方法的具体用法?PHP Entity::isObjectEntity怎么用?PHP Entity::isObjectEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity::isObjectEntity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchRelatedObjectIdsOfEntity
public function fetchRelatedObjectIdsOfEntity(MySQLi $mySQLi, Entity $otherEntity)
{
$queryContext = new QueryContext(array(), NULL);
$scope = Scope::parseValue(Scope::VALUE_C_REF . Scope::VALUE_A_REF . Scope::VALUE_O_REF);
$fetchedObjectIds = array();
if ($otherEntity->isObjectEntity()) {
$fetchedObjectRefs = array();
$this->fetchRelatedObjectRefsOfEntity($mySQLi, $otherEntity, $queryContext, $scope, $fetchedObjectRefs);
foreach ($fetchedObjectRefs as $fetchedObjectRef) {
$fetchedObjectIds[] = $fetchedObjectRef->id;
}
} else {
$fetchedObjectIds[] = 0;
}
return $fetchedObjectIds;
}
示例2: __construct
public function __construct(Entity $fkEntity, array $fkColumnNameToEntityMap, $ownerEntity)
{
$this->fkEntity = $fkEntity;
$this->fkColumnNames = array();
$this->relatedEntities = array();
if ($fkEntity->isObjectEntity() or count($fkColumnNameToEntityMap) < 2) {
$this->relatedEntities[] = $fkEntity;
}
foreach ($fkColumnNameToEntityMap as $fkColumnName => $toEntity) {
$this->fkColumnNames[$toEntity->getId()] = $fkColumnName;
$this->relatedEntities[] = $toEntity;
}
if (count($this->relatedEntities) < 2) {
throw new Exception("Cannot create a Relationship between less than two entities.");
}
if ($ownerEntity != NULL and array_search($ownerEntity, $this->relatedEntities) === FALSE) {
throw new Exception("Owner-entity '" . $ownerEntity->getName() . "' must be either NULL, '" . $this->getOneEntity()->getName() . "' or '" . $this->getOtherEntity()->getName() . "'.");
}
$this->ownerEntity = $ownerEntity;
}
示例3: insertOrUpdate
private function insertOrUpdate(Schema $schema, Entity $entity, $id, array $propertyValues, Audit $audit)
{
$mustInsert = $id == NULL;
$mySQLi = $schema->getMySQLi();
$entityName = $entity->getName();
$stateIdColumnName = $entity->getStateIdColumnName();
// Create a state object if the given entity supports states.
$stateId = NULL;
if ($stateIdColumnName != NULL) {
$queryString = "INSERT INTO " . DbConstants::TABLE_STATE . " (id_created) VALUES(" . $audit->getId() . ")";
$queryResult = $mySQLi->query($queryString);
if (!$queryResult) {
throw new Exception("Error creating state for new object of '{$entityName}'" . " - {$mySQLi->error}\n<!--\n{$queryString}\n-->");
}
$stateId = $mySQLi->insert_id;
// Statefull entities must always be inserted.
$mustInsert = TRUE;
// If no id was given...
if ($id == NULL) {
// ...then use the (auto-incremented) stateId as id.
$id = $stateId;
}
}
// Prepare the input parameters for the insert-query.
$columnNames = array();
$types = '';
$values = array();
// Add the object-id if applicable.
if ($entity->isObjectEntity()) {
// Ensure that primary key properties are not specified explicitly.
foreach ($propertyValues as $propertyName => $value) {
if ($entity->getProperty($propertyName)->getKeyIndicator() == Property::KEY_PRIMARY) {
throw new Exception("Property '{$propertyName}' of '{$entityName}' is a primary key and cannot be changed.");
}
}
// Add the object-id.
$columnNames[] = $entity->getObjectIdColumnName();
$types .= 'i';
$values[] = $id;
}
// Add the state-info if applicable.
if ($stateIdColumnName != NULL) {
$columnNames[] = $stateIdColumnName;
$types .= 'i';
$values[] = $stateId;
}
$blobs = array();
foreach ($propertyValues as $columnName => $value) {
$property = $entity->getProperty($columnName);
$columnNames[] = $property->getName();
$typeIndicator = $property->getTypeIndicator();
switch ($typeIndicator) {
case Property::TYPE_TEXT:
case Property::TYPE_TIMESTAMP:
$types .= 's';
break;
case Property::TYPE_BINARY:
$types .= 'b';
$blobs[count($values)] = $value;
$value = NULL;
break;
case Property::TYPE_DOUBLE:
$types .= 'd';
break;
case Property::TYPE_INTEGER:
$types .= 'i';
break;
default:
throw new Exception("Unknown type indicator '{$typeIndicator}'.");
}
$values[] = $value;
}
// Compose the query string...
$queryString = NULL;
if ($mustInsert) {
$queryString = "INSERT INTO {$entityName} (" . implode(',', $columnNames) . ") VALUES(";
for ($i = 0; $i < count($columnNames); $i++) {
$queryString .= '?,';
}
// Remove the last comma.
$queryString = substr($queryString, 0, strlen($queryString) - 1);
$queryString .= ")";
} else {
$queryString = "UPDATE {$entityName} SET ";
foreach ($columnNames as $columnName) {
$queryString .= "{$columnName}=?,";
}
// Remove the last comma.
$queryString = substr($queryString, 0, strlen($queryString) - 1);
if ($entity->isObjectEntity()) {
$queryString .= " WHERE " . $entity->getObjectIdColumnName() . " = " . $id;
}
}
// ...and prepare the query.
$stmt = $mySQLi->prepare($queryString);
if ($stmt === FALSE) {
throw new Exception("Error creating prepared statement to insert '{$entityName}' - " . "{$mySQLi->error}\n<!--\n{$queryString}\n-->");
}
// Don't throw exceptions before closing the prepared statement.
$exception = NULL;
//.........这里部分代码省略.........