本文整理汇总了PHP中Entity::setId方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::setId方法的具体用法?PHP Entity::setId怎么用?PHP Entity::setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity::setId方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save(Entity $entity)
{
$data = array('name' => $entity->getName(), 'email' => $entity->getEmail(), 'phone' => $entity->getPhone(), 'message' => $entity->getMessage(), 'date' => $entity->getDate());
if ($entity->getId() > 0) {
$this->db->update($this->table, $data, $entity->getId());
} else {
$entity->setId($this->db->insert($this->table, $data));
}
}
示例2: save
public function save(Entity $entity)
{
$data = array('username' => $entity->getUsername(), 'password' => $entity->getPassword());
if ($entity->getId() > 0) {
$this->db->update($this->table, $data, $entity->getId());
} else {
$entity->setId($this->db->insert($this->table, $data));
}
}
示例3: save
public function save(Entity $entity)
{
$data = array('product_id' => $entity->getProductId(), 'date' => $entity->getDate(), 'name' => $entity->getName(), 'email' => $entity->getEmail(), 'phone' => $entity->getPhone(), 'is_complete' => $entity->getIsComplete(), 'user_id' => $entity->getUserId());
if ($entity->getId() > 0) {
$this->db->update($this->table, $data, $entity->getId());
} else {
$entity->setId($this->db->insert($this->table, $data));
}
}
示例4: save
public function save(Entity $entity)
{
$data = array('title' => $entity->getTitle(), 'content' => $entity->getContent());
if ($entity->getId() > 0) {
$this->db->update($this->table, $data, $entity->getId());
} else {
$entity->setId($this->db->insert($this->table, $data));
}
}
示例5: save
public function save(Entity $entity)
{
$data = array('name' => $entity->getName(), 'content' => $entity->getContent(), 'date' => date('Y-m-d H:i:s', strtotime($entity->getDate())), 'news_id' => $this->news_id);
if ($entity->getId() > 0) {
$this->db->update($this->table, $data, $entity->getId());
} else {
$entity->setId($this->db->insert($this->table, $data));
}
}
示例6: arrayToEntity
protected function arrayToEntity(array $array)
{
$entity = new Entity();
$entity->setId($array['id']);
$entity->setIdentifier($array['identifier']);
$entity->setReceived($array['received']);
$entity->setSend($array['send']);
$entity->setSuccess($array['success']);
return $entity;
}
示例7: save
public function save(Entity $entity)
{
$data = array('product_id' => $entity->getProductId());
if ($entity->getImage() != '') {
$data['image'] = $entity->getImage();
}
if ($entity->getId() > 0) {
$this->db->update($this->table, $data, $entity->getId());
} else {
$entity->setId($this->db->insert($this->table, $data));
}
}
示例8: save
public function save(Entity $entity)
{
$data = array('title' => $entity->getTitle(), 'description' => $entity->getDescription(), 'price' => $entity->getPrice());
if ($entity->getImage() != '') {
$data['image'] = $entity->getImage();
}
if ($entity->getId() > 0) {
$this->db->update($this->table, $data, $entity->getId());
} else {
$entity->setId($this->db->insert($this->table, $data));
}
}
示例9: save
public function save(Entity $entity)
{
$data = array('title' => $entity->getTitle(), 'content' => $entity->getContent(), 'author' => $entity->getAuthor(), 'date' => date('Y-m-d H:i:s', strtotime($entity->getDate())));
if ($entity->getImage() != '') {
$data['image'] = $entity->getImage();
}
if ($entity->getId() > 0) {
$this->db->update($this->table, $data, $entity->getId());
} else {
$entity->setId($this->db->insert($this->table, $data));
}
}
示例10: findWhere
public function findWhere($keys, $values)
{
$tag = "EntityDAO: findWhere()";
Log::notice("{$tag}: ({$keys}, {$values})");
$blueprint = $this->blueprint;
$timezone_offset = $this->timezone_offset_select;
$blueprintKey = $this->tableName();
$query = new EntityQuery($blueprint, $timezone_offset);
if (!is_array($keys) && !is_array($values)) {
// convert non-array arguments into single element arrays
$keys = array($keys);
$values = array($values);
} else {
if (is_array($keys) && !is_array($values) || count($keys) != count($values)) {
throw new Exception("Length of (key,value) arguments do not match");
}
}
try {
for ($i = 0; $i < count($keys); $i++) {
$key = $keys[$i];
$value = $values[$i];
$field = $blueprint->get($key);
switch ($field->getDataType()) {
case "int":
$query->where("{$blueprintKey}.{$key}={$value}");
break;
case "datetime":
case "time":
$query->where("{$blueprintKey}.{$key}=CONVERT_TZ('{$value}', '{$timezone_offset}', '" . BPTimezone::UTC . "')");
break;
default:
$query->where("{$blueprintKey}.{$key}='{$value}'");
break;
}
}
} catch (Exception $e) {
Log::error("{$tag}: Field [{$key}] is not defined by [" . $blueprint->getKey() . "]");
throw $e;
}
try {
$sql = new DatabaseQuery($query->toString());
$sql->doQuery();
$matches = array();
$num_rows = $sql->get_num_rows();
Log::debug("{$tag}: Found {$num_rows} matches");
for ($i = 0; $i < $sql->get_num_rows(); $i++) {
$row = $sql->get_next_row();
$entity = new Entity($blueprint);
$entity->setId($row->id);
$entity->setModified($row->modified);
foreach ($blueprint->fields() as $field) {
$key = $field->getKey();
$value = $row->{$key};
if ($field->isForeignKey()) {
$foreignValueColumn = str_replace(".", "_", $field->getForeignValue());
$foreignValue = $row->{$foreignValueColumn};
$entity->setForeignValue($key, $foreignValue);
}
switch ($field->getDataType()) {
case "binary":
if (get_magic_quotes_gpc()) {
$value = stripslashes($str);
}
$lengthKey = $key . "_length";
$length = $row->{$lengthKey};
$entity->length($key, $length);
break;
}
$entity->set($key, $value);
}
$matches[] = $entity;
}
return $matches;
} catch (Exception $e) {
Log::error("{$tag}: [" . $sql->err_code . "] " . $sql->err_message);
throw $e;
}
}
示例11: relationshipProvider
public function relationshipProvider()
{
$child = new Child();
$child->setId($this->childId);
$child->setTheirField($this->childTheirField);
$insertEntity = new Entity();
$insertEntity->setChild($child);
$updateEntity = new Entity();
$updateEntity->setId(9);
$updateEntity->setChild($child);
return [[[$insertEntity], ["Silktide\\Reposition\\Sql\\Test\\QueryInterpreter\\Type\\Child" => [EntityMetadata::METADATA_RELATIONSHIP_TYPE => EntityMetadata::RELATIONSHIP_TYPE_ONE_TO_ONE, EntityMetadata::METADATA_RELATIONSHIP_PROPERTY => "child", EntityMetadata::METADATA_RELATIONSHIP_OUR_FIELD => "child_id", EntityMetadata::METADATA_RELATIONSHIP_THEIR_FIELD => null]], "INSERT INTO `{$this->collection}` (`field_1`, `child_id`) VALUES (:value_0, :value_1)", ["value_1" => $this->childId]], [[$insertEntity], [[EntityMetadata::METADATA_RELATIONSHIP_TYPE => EntityMetadata::RELATIONSHIP_TYPE_ONE_TO_ONE, EntityMetadata::METADATA_RELATIONSHIP_PROPERTY => "child", EntityMetadata::METADATA_RELATIONSHIP_OUR_FIELD => "", EntityMetadata::METADATA_RELATIONSHIP_THEIR_FIELD => null]], "INSERT INTO `{$this->collection}` (`field_1`) VALUES (:value_0)"], [[$insertEntity], [[EntityMetadata::METADATA_RELATIONSHIP_TYPE => EntityMetadata::RELATIONSHIP_TYPE_ONE_TO_MANY, EntityMetadata::METADATA_RELATIONSHIP_PROPERTY => "child", EntityMetadata::METADATA_RELATIONSHIP_THEIR_FIELD => "whatever"]], "INSERT INTO `{$this->collection}` (`field_1`) VALUES (:value_0)"], [[$insertEntity], [[EntityMetadata::METADATA_RELATIONSHIP_TYPE => EntityMetadata::RELATIONSHIP_TYPE_ONE_TO_ONE, EntityMetadata::METADATA_RELATIONSHIP_PROPERTY => "child", EntityMetadata::METADATA_RELATIONSHIP_OUR_FIELD => "child_id", EntityMetadata::METADATA_RELATIONSHIP_THEIR_FIELD => "their_field"]], "INSERT INTO `{$this->collection}` (`field_1`, `child_id`) VALUES (:value_0, :value_1)", ["value_1" => $this->childTheirField]], [[$updateEntity], [[EntityMetadata::METADATA_RELATIONSHIP_TYPE => EntityMetadata::RELATIONSHIP_TYPE_ONE_TO_ONE, EntityMetadata::METADATA_RELATIONSHIP_PROPERTY => "child", EntityMetadata::METADATA_RELATIONSHIP_OUR_FIELD => "child_id", EntityMetadata::METADATA_RELATIONSHIP_THEIR_FIELD => null]], "UPDATE `{$this->collection}` SET `field_1` = :value_0, `child_id` = :value_1 WHERE `id` = :searchId", ["value_1" => $this->childId]]];
}