2009-02-02 14:55:50 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Doctrine\Tests\Models\CMS;
|
|
|
|
|
|
|
|
/**
|
2009-02-18 10:59:11 +03:00
|
|
|
* CmsAddress
|
2009-02-02 14:55:50 +03:00
|
|
|
*
|
2009-02-18 10:59:11 +03:00
|
|
|
* @author Roman S. Borschel
|
2009-05-29 14:23:13 +04:00
|
|
|
* @Entity
|
|
|
|
* @Table(name="cms_addresses")
|
2012-02-26 23:51:39 +04:00
|
|
|
*
|
|
|
|
* @NamedNativeQueries({
|
|
|
|
* @NamedNativeQuery(
|
|
|
|
* name = "find-all",
|
|
|
|
* resultSetMapping = "mapping-find-all",
|
|
|
|
* query = "SELECT id, country, city FROM cms_addresses"
|
2012-02-27 04:10:19 +04:00
|
|
|
* ),
|
|
|
|
* @NamedNativeQuery(
|
|
|
|
* name = "find-by-id",
|
|
|
|
* resultClass = "CmsAddress",
|
|
|
|
* query = "SELECT * FROM cms_addresses WHERE id = ?"
|
|
|
|
* ),
|
|
|
|
* @NamedNativeQuery(
|
|
|
|
* name = "count",
|
|
|
|
* resultSetMapping= "mapping-count",
|
|
|
|
* query = "SELECT COUNT(*) AS count FROM cms_addresses"
|
2012-02-26 23:51:39 +04:00
|
|
|
* )
|
|
|
|
* })
|
|
|
|
*
|
|
|
|
* @SqlResultSetMappings({
|
|
|
|
* @SqlResultSetMapping(
|
|
|
|
* name = "mapping-find-all",
|
|
|
|
* entities= {
|
|
|
|
* @EntityResult(
|
|
|
|
* entityClass = "CmsAddress",
|
|
|
|
* fields = {
|
|
|
|
* @FieldResult(name = "id", column="id"),
|
|
|
|
* @FieldResult(name = "city", column="city"),
|
|
|
|
* @FieldResult(name = "country", column="country")
|
|
|
|
* }
|
|
|
|
* )
|
|
|
|
* }
|
2012-02-27 04:10:19 +04:00
|
|
|
* ),
|
|
|
|
* @SqlResultSetMapping(
|
|
|
|
* name = "mapping-without-fields",
|
|
|
|
* entities= {
|
|
|
|
* @EntityResult(
|
|
|
|
* entityClass = "__CLASS__"
|
|
|
|
* )
|
|
|
|
* }
|
|
|
|
* ),
|
|
|
|
* @SqlResultSetMapping(
|
|
|
|
* name = "mapping-count",
|
|
|
|
* columns = {
|
|
|
|
* @ColumnResult(
|
|
|
|
* name = "count"
|
|
|
|
* )
|
|
|
|
* }
|
2012-02-26 23:51:39 +04:00
|
|
|
* )
|
|
|
|
* })
|
|
|
|
*
|
2009-02-02 14:55:50 +03:00
|
|
|
*/
|
|
|
|
class CmsAddress
|
|
|
|
{
|
|
|
|
/**
|
2009-05-29 14:23:13 +04:00
|
|
|
* @Column(type="integer")
|
2010-04-10 02:00:36 +04:00
|
|
|
* @Id @GeneratedValue
|
2009-02-02 14:55:50 +03:00
|
|
|
*/
|
|
|
|
public $id;
|
2009-02-18 10:59:11 +03:00
|
|
|
|
2009-02-02 14:55:50 +03:00
|
|
|
/**
|
2010-04-10 02:00:36 +04:00
|
|
|
* @Column(length=50)
|
2009-02-02 14:55:50 +03:00
|
|
|
*/
|
|
|
|
public $country;
|
2009-02-18 10:59:11 +03:00
|
|
|
|
2009-02-02 14:55:50 +03:00
|
|
|
/**
|
2010-04-10 02:00:36 +04:00
|
|
|
* @Column(length=50)
|
2009-02-02 14:55:50 +03:00
|
|
|
*/
|
|
|
|
public $zip;
|
2009-02-18 10:59:11 +03:00
|
|
|
|
2009-02-02 14:55:50 +03:00
|
|
|
/**
|
2010-04-10 02:00:36 +04:00
|
|
|
* @Column(length=50)
|
2009-02-02 14:55:50 +03:00
|
|
|
*/
|
|
|
|
public $city;
|
2009-02-18 10:59:11 +03:00
|
|
|
|
2009-11-01 01:24:29 +03:00
|
|
|
/**
|
|
|
|
* Testfield for Schema Updating Tests.
|
|
|
|
*/
|
|
|
|
public $street;
|
|
|
|
|
2009-02-02 14:55:50 +03:00
|
|
|
/**
|
2011-11-15 00:05:44 +04:00
|
|
|
* @OneToOne(targetEntity="CmsUser", inversedBy="address")
|
2010-08-26 15:47:22 +04:00
|
|
|
* @JoinColumn(referencedColumnName="id")
|
2009-02-02 14:55:50 +03:00
|
|
|
*/
|
|
|
|
public $user;
|
2009-05-13 19:19:27 +04:00
|
|
|
|
|
|
|
public function getId() {
|
|
|
|
return $this->id;
|
|
|
|
}
|
2011-11-14 02:14:31 +04:00
|
|
|
|
2009-10-22 13:10:59 +04:00
|
|
|
public function getUser() {
|
|
|
|
return $this->user;
|
|
|
|
}
|
2009-05-13 19:19:27 +04:00
|
|
|
|
|
|
|
public function getCountry() {
|
|
|
|
return $this->country;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getZipCode() {
|
|
|
|
return $this->zip;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCity() {
|
|
|
|
return $this->city;
|
|
|
|
}
|
2011-11-14 02:14:31 +04:00
|
|
|
|
2009-10-01 16:00:14 +04:00
|
|
|
public function setUser(CmsUser $user) {
|
|
|
|
if ($this->user !== $user) {
|
|
|
|
$this->user = $user;
|
|
|
|
$user->setAddress($this);
|
|
|
|
}
|
|
|
|
}
|
2012-03-10 07:04:46 +04:00
|
|
|
|
|
|
|
public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
|
|
|
|
{
|
|
|
|
$metadata->setPrimaryTable(array(
|
|
|
|
'name' => 'company_person',
|
|
|
|
));
|
|
|
|
|
|
|
|
$metadata->addNamedNativeQuery(array (
|
|
|
|
'name' => 'find-all',
|
|
|
|
'query' => 'SELECT id, country, city FROM cms_addresses',
|
|
|
|
'resultSetMapping' => 'mapping-find-all',
|
|
|
|
));
|
|
|
|
|
|
|
|
$metadata->addNamedNativeQuery(array (
|
|
|
|
'name' => 'find-by-id',
|
|
|
|
'query' => 'SELECT * FROM cms_addresses WHERE id = ?',
|
|
|
|
'resultClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsAddress',
|
|
|
|
));
|
|
|
|
|
|
|
|
$metadata->addNamedNativeQuery(array (
|
|
|
|
'name' => 'count',
|
|
|
|
'query' => 'SELECT COUNT(*) AS count FROM cms_addresses',
|
|
|
|
'resultSetMapping' => 'mapping-count',
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
$metadata->addSqlResultSetMapping(array (
|
|
|
|
'name' => 'mapping-find-all',
|
|
|
|
'columns' => array(),
|
|
|
|
'entities' => array ( array (
|
|
|
|
'fields' => array (
|
|
|
|
array (
|
|
|
|
'name' => 'id',
|
|
|
|
'column' => 'id',
|
|
|
|
),
|
|
|
|
array (
|
|
|
|
'name' => 'city',
|
|
|
|
'column' => 'city',
|
|
|
|
),
|
|
|
|
array (
|
|
|
|
'name' => 'country',
|
|
|
|
'column' => 'country',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'entityClass' => 'Doctrine\Tests\Models\CMS\CmsAddress',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
));
|
|
|
|
|
|
|
|
$metadata->addSqlResultSetMapping(array (
|
|
|
|
'name' => 'mapping-without-fields',
|
|
|
|
'columns' => array(),
|
|
|
|
'entities' => array(array (
|
|
|
|
'entityClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsAddress',
|
|
|
|
'fields' => array()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
));
|
|
|
|
|
|
|
|
$metadata->addSqlResultSetMapping(array (
|
|
|
|
'name' => 'mapping-count',
|
|
|
|
'columns' =>array (
|
|
|
|
array (
|
|
|
|
'name' => 'count',
|
|
|
|
),
|
|
|
|
)
|
|
|
|
));
|
|
|
|
}
|
2009-02-18 10:59:11 +03:00
|
|
|
}
|