I'm also have some problems with saveAll. This are the content of this
data and the relations of my model.
# $this->data
Array
(
[Usuario] => Array
(
[PK_usuario] =>
[flPf] => 1
[strNome] => Gildonei Mendes Anacleto Junior
[strLogin] => root
[strSenha] => af47g5t
[strEmail] => jun...@sitecomarte.com.br
[intTelefone] =>
[intCelular] => (48)8413-4280
[flSexoMasc] => 1
[tpUsuario] => 2
[flAtivo] => 1
)
[UsuarioPf] => Array
(
[strRg] => 3879169
[intCpf] => 034.306.469-36
)
[Endereco] => Array
(
[0] => Array
(
[FK_estado] => 24
[FK_cidade] => 10
[strBairro] => Capoeiras
[strEndereco] => Srv. Alzira Ventura Vieira
[intNumero] => 40
[intCep] => 88090175
[strComplemento] => Bloco 04 Apto 301
)
)
)
# Model Usuario
class Usuario extends AppModel
{
public $name = 'Usuario';
public $useTable = 'usuarios';
public $primaryKey = 'PK_usuario';
public $hasOne = array(
'UsuarioPf' => array(
'className' => 'UsuarioPf',
'foreignKey' => 'PK_usuario',
'type' => 'LEFT'
),
'UsuarioPj' => array(
'className' => 'UsuarioPj',
'foreignKey' => 'PK_usuario',
'type' => 'LEFT'
)
);
#Model UsuarioPf
class UsuarioPf extends AppModel
{
public $name = 'UsuarioPf';
public $useTable = 'usuario_pfs';
public $primaryKey = 'PK_usuario';
public $displayField = 'intCpf';
public $belongsTo = array(
'Usuario' => array(
'className' => 'Usuario',
'foreignKey' => 'PK_usuario',
'type' => 'INNER'
)
);
# Model Endereco
class Endereco extends AppModel
{
public $name = 'Endereco';
public $useTable = 'enderecos';
public $primaryKey = 'PK_endereco';
public $belongsTo = array(
'Cidade' => array(
'className' => 'Cidade',
'foreignKey' => 'FK_cidade',
'type' => 'INNER'
),
'Usuario' => array(
'className' => 'Usuario',
'foreignKey' => 'FK_usuario',
'type' => 'INNER'
)
);
# SQL CallBacks
1 DESCRIBE `usuarios` 10 10 3
2 DESCRIBE `usuario_pfs` 3 3 4
3 DESCRIBE `usuario_pjs` 4 4 4
4 DESCRIBE `enderecos`7 7 4
5 DESCRIBE `cidades` 3 3 4
6 DESCRIBE `estados` 3 3 3
7 DESCRIBE `pagamentos` 4 4 4
8 DESCRIBE `setores` 5 5 4
9 DESCRIBE `imagens` 9 9 4
10 SELECT `Usuario`.`PK_usuario` FROM `usuarios` AS `Usuario` LEFT
JOIN `usuario_pfs` AS `UsuarioPf` ON (`UsuarioPf`.`PK_usuario` =
`Usuario`.`PK_usuario`) LEFT JOIN `usuario_pjs` AS `UsuarioPj` ON
(`UsuarioPj`.`PK_usuario` = `Usuario`.`PK_usuario`) WHERE `strLogin` =
'root' AND `Usuario`.`PK_usuario` <> "" LIMIT 1 0 0 1
11 START TRANSACTION 0 1
12 ROLLBACK0 1
13 SELECT `Estado`.`PK_estado`, `Estado`.`strNome` FROM `estados` AS
`Estado` WHERE 1 = 127 27 1
14 SELECT `Setor`.`PK_setor`, `Setor`.`strNome`,
`Setor`.`strDescricao`, `Setor`.`strController`, `Setor`.`flMenu` FROM
`setores` AS `Setor` WHERE `flMenu` = 1 10 10 1
15 SELECT `Imagem`.`PK_imagem`, `Imagem`.`FK_setor`,
`Imagem`.`FK_registro`, `Imagem`.`strNome`, `Imagem`.`strNomeDisco`,
`Imagem`.`strMime`, `Imagem`.`intSize`, `Imagem`.`intWidth`,
`Imagem`.`intHeight` FROM `imagens` AS `Imagem` WHERE
`Imagem`.`FK_setor` IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) 0 0 0
Does anyone can help us?
Ty.
On 30 jul, 04:04, Vijay Kumbhar wrote:
> It is not working while saving the data while adding the data or while
> editing the existing data?
>
> I have the same problem with cakephp 1.3 but while editing the associated
> model data using saveAll.
> If it is not saving the data while editing then in cakephp 1.3 you have to
> specify the related model primary key with the edited record.
>
> You have to take the profile id field in you form. So that you can get it
> after posting the form.
>
> $this->User->UserProfile->id