Created
May 6, 2016 12:52
-
-
Save cesarAugusto1994/24ab4ac78a813c6ef742308b2aecf586 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Created by PhpStorm. | |
* User: cesar | |
* Date: 06/05/16 | |
* Time: 09:15 | |
*/ | |
require(dirname(__FILE__) . "/../includes/funcoes.inc.php"); | |
require(dirname(__FILE__) . "/../includes/geral.class.php"); | |
include(dirname(__FILE__) . "/../includes/global.php"); | |
$arquivo = fopen('nomes_lojas.csv', 'r'); | |
$count = 0; | |
while (!feof($arquivo)) { | |
$linha = fgets($arquivo, 1024); | |
$dados = explode(';', $linha); | |
if(empty($dados[2])){ | |
throw new Exception('Noma da Loja não informado. Nº:' . $dados[2]); | |
} | |
if ($dados[2] != '' && !empty($linha)) { | |
$query = " | |
UPDATE " . g_str_webpdv . ".empresa_filial SET | |
nome_filial = '" . utf8_decode($dados[2]) . "' | |
WHERE storeno = " . $dados[0] . " | |
"; | |
g_arr_executa_query($query, 'update'); | |
} | |
$query2 = " SELECT storeno, nome_filial FROM webpdv.empresa_filial WHERE storeno = " . $dados[0]; | |
$resultado = g_arr_executa_query($query2); | |
echo 'Loja: ' . $resultado[0]['storeno'] . ' Nome: ' . $resultado[0]['nome_filial']; | |
echo '<hr>'; | |
} | |
fclose($arquivo); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment