数据插入数据库空白

时间:2017-11-08 18:40:11

标签: php database magento

我将数据插入magento客户的地址,我可以添加除街道字段以外的所有字段,有人知道为什么吗? 没有输入数据,没有显示任何错误,其他字段都是文本或选择,所以通常,这个字段只有一个标签,我得到数据库标签,我给一个var_dump,它返回地址,但是没有添加,我认为我在setStreet1,setStreet2,setStreet3,setStreet4上错了。

我是否必须以任何不同的方式输入这些值?如何在数据库中设置此数据?我会以不同的方式设置它们吗?我通常通过名称first_name = Firstname将数据放入银行,在这里我尝试做同样的事情,但在街上它不同就像[street] [0],enter image description here。其他数据类似于[first_name],[last_name]。因为他打开另一个[]我是否必须以另一种方式添加它?

我提取此信息的方式是

' rua' => $ usuario_loaded-> getStreet1(),' numero' => $ usuario_loaded-> getStreet2(),' complemento&#39 ; => $ usuario_loaded-> getStreet3(),' bairro' => $ usuario_loaded-> getStreet4()

                    $i = 1;

                    $link = mysqli_connect('localhost','root','','x');
                    $link->set_charset("utf8");
                    $query = "SELECT * from endereços";
                    $select = mysqli_query($link, $query);
                    foreach ($select as $key => $selects) {
                    $link = mysqli_connect('localhost','root','','x');
                    $link->set_charset("utf8");
                    $query = "SELECT * from endereços";
                    $select = mysqli_query($link, $query);
                    while($row = mysqli_fetch_array($select)){
                    $teste = array(
                            $endereço_id = $row['endereço_id'],
                            $nome = $row['nome'],
                            $assinatura = $row['assinatura'],
                            $sobrenome = $row['sobrenome'],
                            $rua = $row['rua'],
                            $numero = $row['numero'],
                            $complemento = $row['complemento'],
                            $bairro = $row['bairro'],
                            $cidade = $row['cidade'],
                            $país = $row['país'],
                            $estado = $row['estado'],
                            $cep = $row['cep'],
                            $telefone = $row['telefone'],
                            );

                            var_dump($teste);

                            $customer = Mage::getModel("customer/address");
                            $customer   ->setId($endereço_id)
                                        ->setFirstname($nome)
                                        ->setMiddlename($assinatura)
                                        ->setLastname($sobrenome)
                                        ->setStreet1($rua)
                                        ->setStreet2($numero)
                                        ->setStreet3($complemento)
                                        ->setStreet4($bairro)
                                        ->setCity($cidade)
                                        ->setCountryId($país)
                                        ->setRegionId($estado)
                                        ->setPostcode($cep)
                                        ->setTelephone($telefone)

                            try{
                                    $customer->save();
                                }
                                catch (Exception $e) {
                                    Zend_Debug::dump($e->getMessage());
                                }
                            }
                    }

图片

enter image description here

1 个答案:

答案 0 :(得分:0)

我做了,我只需要用数组添加数据。仅更改此行

-> setStreet (array ($rua, $numero, $complemento, $bairro))