Saturday, July 31, 2010

Re: saveAll does'nt work

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] => junior@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 ROLLBACK 0 1
13 SELECT `Estado`.`PK_estado`, `Estado`.`strNome` FROM `estados` AS
`Estado` WHERE 1 = 1 27 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 <k.vidn...@gmail.com> 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 = $this->data['UserProfile']['id'];
>
> If you have defined your associations correctly between the models then it
> has to work.
>
> If you have the relation then please recheck the associations or please put
> the code here so that we can verify it & tell you appropriate solution.
>
> On Fri, Jul 30, 2010 at 11:29 AM, Norman Paniagua
> <normanpania...@gmail.com>wrote:
>
>
>
> > Can you put the model code?
> > ---
>
> > Norman Paniagua
>
> > 2010/7/30 Jeremy <shimeilin1...@gmail.com>
>
> > today, I find function saveAll can not work ,when save data into two
> >> relations tables, blew is the data,
>
> >> Array
> >> (
> >>    [User] => Array
> >>        (
> >>            [username] => tester
> >>            [password] => 17acdc1ee8e4ed05e9d27fce4df6d4b5de036910
> >>            [email] => tes...@admin.com
> >>            [country_id] => 180
> >>            [captcha_input] => uhrfca
> >>            [reg_ip] => 172.16.5.73
> >>            [confirm_code] => 4c526005-2038-4c84-b01f-0ccec0a8061f
> >>        )
>
> >>    [UserProfile] => Array
> >>        (
> >>            [birth] => 2009-02-12
> >>        )
>
> >> ), and mysql ENGINE is MyISAM , anyone know the reason ?  help me !!!
>
> >> Check out the new CakePHP Questions sitehttp://cakeqs.organd help
> >> others with their CakePHP related questions.
>
> >> You received this message because you are subscribed to the Google Groups
> >> "CakePHP" group.
> >> To post to this group, send email to cake-php@googlegroups.com
> >> To unsubscribe from this group, send email to
> >> cake-php+unsubscribe@googlegroups.com<cake-php%2Bunsubscribe@googlegroups.com>For more options, visit this group at
> >>http://groups.google.com/group/cake-php?hl=en
>
> >  Check out the new CakePHP Questions sitehttp://cakeqs.organd help
> > others with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com<cake-php%2Bunsubscribe@googlegroups.com>For more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en
>
> --
> Thanks & Regards,
> Vijayk.
>
> "You Bring the Dreams, We'll Bring the Means"

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: