Dont work has one retation
- FromRussia
- Member | 7
Hi! i am use ActiveRow
$clients = $this->database->table('clients');
foreach($clients as $client){
dump($client);
dump($client->ref('clients_enterpneur', 'id_client'));
echo '<hr>';
}
have error
No reference found for $clients->ref(clients_enterpneur)
use has many, it work
$clients = $this->database->table('clients');
foreach($clients as $client){
dump($client);
foreach($client->related('clients_enterpneur.id_client') as $item){
dump($item);
}
echo '<hr>';
}
DB
clients
CREATE TABLE IF NOT EXISTS clients
(
id
int(11) NOT NULL,
legal_type
varchar(1) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
clients_enterpneur
CREATE TABLE IF NOT EXISTS clients_enterpneur
(
id_client
int(11) NOT NULL,
name
varchar(45) DEFAULT NULL,
person_first_name
varchar(45) DEFAULT NULL,
person_last_name
varchar(45) DEFAULT NULL,
ICO
decimal(10,0) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
what is the problem?
- FromRussia
- Member | 7
CZechBoY wrote:
Use method related, because you use 1:M relation… if you want 1:1 the foreign column should be in clients table (id_clients_enterpneu).
Thank you! I'm sorry that is not the topic.
Someone knows the plug-in to connect AcriveRecord Nette?
- FromRussia
- Member | 7
Or is there a way to set the ratio
from ‘tablename’ ⇒ ‘field’ to ‘tablename’ ⇒ ‘filed’