Answer the question
In order to leave comments, you need to log in
I work with the 1 to 1 relationship doctrine, I select the related entity, but for some reason it is empty?
productmodel
Asu\Models\ProductModel:
type: entity
table: product
id:
id:
type: integer
length: 10
column: product_id
generator:
strategy: AUTO
fields:
priceId:
type: integer
length: 10
column: price_id
oneToOne:
price:
targetEntity: Asu\Models\PriceModel
joinColumn:
name: price_id
referencedColumnName: price_id
Asu\Models\PriceModel:
type: entity
table: price
id:
id:
type: integer
length: 10
column: price_id
generator:
strategy: AUTO
public function setPrice($price)
{
$this->price = $price;
return $this;
}
public function addPrice($price)
{
$this->setPrice($price);
}
public function getPrice()
{
return $this->price;
}
$product = $productRepo->findOneBy(['code' => 'АН', 'number' => '101',
'color' => 'БД']);
$price = $product->getPrice();
Answer the question
In order to leave comments, you need to log in
Here is the missing piece:
fields:
priceId:
type: integer
length: 10
column: price_id
The problem turned out to be that I used __call () it was just on the links and it broke.
Though normally gave out values at normal sampling.
public function __call($namefunction, $arguments)
{
if (strlen($nameFunction) < 4):
return;
endif;
$prefix = substr($nameFunction, 0, 3);
$name = lcfirst(substr($nameFunction, 3, strlen($nameFunction) - 3));
$inFields = array_search($name, self::$fields);
if ($prefix == 'get'):
if ($inFields):
return $this->$name;
endif;
endif;
if ($prefix == 'set'):
if ($inFields):
$value = $arguments[0];
$this->$name = $value;
endif;
endif;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question