function arrayUtf8Enconde($array) { //instancia um novo array $novo = array(); //entar em um loop para verificar e converter cada indice do array foreach ($array as $i => $value) { //verifica se o indice é um array if (is_array($value)) { //aqui chama novamente o próprio método para verificar novamente(recursividade) $value = arrayUtf8Enconde($value); } elseif (!mb_check_encoding($value, 'UTF-8')) { //se não for array, verifica se o valor está codificado como UTF-8 //aqui ele codifica $value = utf8_encode($value); } //recoloca o valor no array $novo[$i] = $value; } //retorna o array return $novo; }
public function executaSQL($_prStringSQL = '', $SQL = false, Sql $_prTransacao = null) { unset($this->StlRETORNO); if ($_prStringSQL == '') { $_prStringSQL = $this->StringSQL; } if ($this->LIMITFINAL > 0) { $_prStringSQL .= " LIMIT {$this->LIMITINICI}, {$this->LIMITFINAL}"; } $this->StringSQL = $_prStringSQL; $temTransacao = false; if ($_prTransacao != null) { $this->PRSCONEXAO = $_prTransacao->PRSCONEXAO; } else { if ($this->PRSCONEXAO == null) { $conexao = new Conexao(); $conexao->conectar(); $this->PRSCONEXAO = $conexao->getConexao(); $temTransacao = true; } } gravaLog($_prStringSQL); if ($SQL) { $retorno = @mysqli_query($this->PRSCONEXAO, $_prStringSQL); return $retorno; } else { $Aux = @mysqli_query($this->PRSCONEXAO, $_prStringSQL); for ($i = 0; $i < @mysqli_num_rows($Aux); $i++) { $this->StlRETORNO[$i] = @mysqli_fetch_assoc($Aux); } return arrayUtf8Enconde($this->StlRETORNO); } if ($temTransacao) { $conexao->desconectar(); } }