Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problema verificacion #72

Open
Mohicanorr opened this issue Jun 10, 2017 · 2 comments
Open

problema verificacion #72

Mohicanorr opened this issue Jun 10, 2017 · 2 comments

Comments

@Mohicanorr
Copy link

Hola a todos, hoy entro en esta productiva comunidad de desarrollo por primera vez, para suplirles con lo que pueda y , como no, poder enriquecerme de vuestra sabiduría.
Quisiera saber si alguien ha usado el componente mencionado en el título (Goodby/csv) para PHP, debido a que tengo un problema con el mismo. Les explico, estoy desarrollando una aplicacion que gestiona licencias de software donde los usuarios se cargan mediante ficheros csv a una BD MySQL y para ello quiero contemplar que cada vez que subo un fichero con los profesores, se compruebe cada registro (fila del csv) para ver si existe en la BD y no duplicarlo. El problema es que el componente parece ser que hace un bucle impícito de todas las sentencias que están delimitadas (csv) y en ese intervalo no puedo comprobar cada fila para dicho propósito. Les paso el código a ver si podéis verlo con claridad.

Esta es una de la funciones que se encargan de lo comentado:

introducir el código aquí

public function InsertarProfesores($ficheroTmp){
try{
$config = new LexerConfig();
$config
->setDelimiter(";") // Customize delimiter. Default value is comma(,)
->setEnclosure("'") // Customize enclosure. Default value is double quotation(")
->setEscape("\") // Customize escape character. Default value is backslash()
->setToCharset('UTF-8') // Customize target encoding. Default value is null, no converting.

			;
			$lexer = new Lexer($config);
			$interpreter = new Interpreter();
			$pdo = $this->pdo;
			$interpreter->addObserver(function(array $columns) use ($pdo) {
				
				$stmt = $pdo->prepare('INSERT INTO profesores (departamento,dni,nombre, primer_apellido, segundo_apellido,tlf_sms,direccion,email,num_afiliacion, tutor_de) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
				$stmt->execute($columns);
			});
			
			$lexer->parse($ficheroTmp, $interpreter);

		}catch(Exception $e){
			die($e->getMessage());
		}
	}

Si podeis ayudarme lo agradecería enormemente debido a que es para un trabajo y necesito solventarlo cuanto antes.

Saludos

@Mohicanorr
Copy link
Author

Re edit, in English:

Hello everyone, today I enter this productive community of development for the first time, to supply them with what I can and, of course, to be able to enrich myself with your wisdom.
I would like to know if someone has used the components mentioned in the title (Goodby / csv) for PHP, because I have a problem with it. I explain, I am developing an application that manages software licenses where users are uploaded using csv files to a MySQL BD and for this I want to contemplate every time I upload a file with the teachers, check each record (csv row) to see If it exists in the DB and does not duplicate it. The problem is that the component seems to be doing an impractical loop of all the statements that are bounded (csv) and in that interval I can not check each row for that purpose. The code to see if you can see it clearly.

This is one of the functions that are responsible for what is commented:

public function InsertarProfesores($ficheroTmp){
try{
$config = new LexerConfig();
$config
->setDelimiter(";") // Customize delimiter. Default value is comma(,)
->setEnclosure("'") // Customize enclosure. Default value is double quotation(")
->setEscape("") // Customize escape character. Default value is backslash()
->setToCharset('UTF-8') // Customize target encoding. Default value is null, no converting.

		;
		$lexer = new Lexer($config);
		$interpreter = new Interpreter();
		$pdo = $this->pdo;
		$interpreter->addObserver(function(array $columns) use ($pdo) {
			
			$stmt = $pdo->prepare('INSERT INTO profesores (departamento,dni,nombre, primer_apellido, segundo_apellido,tlf_sms,direccion,email,num_afiliacion, tutor_de) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
			$stmt->execute($columns);
		});
		
		$lexer->parse($ficheroTmp, $interpreter);

	}catch(Exception $e){
		die($e->getMessage());
	}
}

If you can help me I would greatly appreciate it because it is for a job and I need to solve it as soon as possible, I Only have today to solve this issue!

regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@Mohicanorr and others