I'm trying to insert some data into the bank via php, but it can not add that data, would anyone know what it might be? I give a var_dump in the array to know if it is pulling the data correctly and it is. I'm trying to pull data from one table and send it to another. Just this, in case I can not do this would I have to save the data I am pulling in a .sql file? How would I do this with php?
var_dump result
array(27) {
[0]=>
string(1) "5"
[1]=>
string(1) "5"
[2]=>
string(5) "Elvis"
[3]=>
string(9) "Domingues"
[4]=>
string(1) "1"
[5]=>
string(1) "1"
[6]=>
NULL
[7]=>
NULL
[8]=>
string(14) "--------------"
[9]=>
NULL
[10]=>
NULL
[11]=>
NULL
[12]=>
string(13) "teste apelido"
[13]=>
NULL
[14]=>
string(1) "1"
[15]=>
NULL
[16]=>
NULL
[17]=>
NULL
[18]=>
string(33) "elvis.domingues@----------"
[19]=>
NULL
[20]=>
NULL
[21]=>
string(19) "1979-04-06 00:00:00"
[22]=>
string(11) "------------"
[23]=>
string(1) "1"
[24]=>
NULL
[25]=>
NULL
[26]=>
NULL
}
Erro ao inserir cliente
Code
$users = Mage::getModel('customer/customer')->getCollection();
$i = 1;
foreach ($users as $key => $user) {
$id = $user->getId();
$usuario_loaded = Mage::getModel('customer/customer')->load($id);
$tudo = array(
$id = $usuario_loaded->getId(),
$clientes_id = $usuario_loaded->getId(),
$nome = $usuario_loaded->getFirstname(),
$sobrenome = $usuario_loaded->getLastname(),
$loja = $usuario_loaded->getWebsiteId(),
$grupo = $usuario_loaded->getGroupId(),
$prefixo = $usuario_loaded->getPrefix(),
$assinatura = $usuario_loaded->getMiddlename(),
$cpf = $usuario_loaded->getCpf(),
$cnpj = $usuario_loaded->getCnpj(),
$razao = $usuario_loaded->getCompanyName(),
$fantasia = $usuario_loaded->getTradingName(),
$apelido = $usuario_loaded->getNickname(),
$insestadual = $usuario_loaded->getIe(),
$tipocadastro = $usuario_loaded->getType(),
$profissao = $usuario_loaded->getOccupation(),
$fundação = $usuario_loaded->getFoundationDay(),
$sufixo = $usuario_loaded->getSuffix(),
$email = $usuario_loaded->getEmail(),
$emailsec = $usuario_loaded->getEmailSeconday(),
$emailfiscal = $usuario_loaded->getEmailBilling(),
$nascimento = $usuario_loaded->getDob(),
$cpfcnpj = $usuario_loaded->getTaxvat(),
$sexo = $usuario_loaded->getGender(),
$departamento = $usuario_loaded->getDepartment(),
$ondeconheceu = $usuario_loaded->getHowFindUs(),
$adyen = $usuario_loaded->getAdyenCustomerRef());
var_dump($tudo);
$strcon = mysqli_connect('localhost','root','','teste2') or die('Erro ao conectar ao banco de dados');
$sql = mysqli_query($strcon,
"INSERT INTO clientes(
id
clientes_id,
nome,
sobrenome,
loja,
grupo,
prefixo,
assinatura,
cpf,
cnpj,
razao,
fantasia,
apelido,
insestadual,
tipocadastro,
profissao,
fundação,
sufixo,
email,
emailsec,
emailfiscal,
nascimento,
cpfcnpj,
sexo,
departamento,
ondeconheceu,
adyen)
VALUES (
'$id',
'$clientes_id',
'$nome',
'$sobrenome',
'$loja',
'$grupo',
'$prefixo',
'$assinatura',
'$cpf',
'$cnpj',
'$razao',
'$fantasia',
'$apelido',
'$insestadual',
'$tipocadastro',
'$profissao',
'$fundação',
'$sufixo',
'$email',
'$emailsec',
'$emailfiscal',
'$nascimento',
'$cpfcnpj',
'$sexo',
'$departamento',
'$ondeconheceu',
'$adyen')");
mysqli_query($strcon,
$sql) or die("Erro ao inserir cliente \n");