$result = mysql_query($query);
if (!$result) {
if (mysql_errno()==1062) { //Duplicate entry
log_info("user already created");
}
else {
throw new Exception("Invalid query, error: " . mysql_error(),$query);
}
}
miércoles, 31 de marzo de 2010
PHP - cómo darse cuenta de un error de insert por duplicate key
miércoles, 24 de marzo de 2010
Cómo generar un jar de json
1. Download http://www.json.org/java/json.zip from json.org. Save it in a some directory, which I'll call %DOWNLOAD_HOME%.
2. Unzip it. Be sure you preserve the archive's directory structure (/org/json/) when you unzip the file.
3. Change directory into %DOWNLOAD_HOME%\org\json
4. Compile the files by running “javac *.java”. At least, this worked for me. There is no build.xml or anything, and it just seemed to compile into classes nicely.
5. CD back into %DOWNLOAD_HOME%
6. Create a jar file called json.jar. The syntax is something like:
jar -cvf json.jar org\json\*.class
Ref: http://processing.org/discourse/yabb2/YaBB.pl?board=Integrate;action=display;num=1163101573
2. Unzip it. Be sure you preserve the archive's directory structure (/org/json/) when you unzip the file.
3. Change directory into %DOWNLOAD_HOME%\org\json
4. Compile the files by running “javac *.java”. At least, this worked for me. There is no build.xml or anything, and it just seemed to compile into classes nicely.
5. CD back into %DOWNLOAD_HOME%
6. Create a jar file called json.jar. The syntax is something like:
jar -cvf json.jar org\json\*.class
Ref: http://processing.org/discourse/yabb2/YaBB.pl?board=Integrate;action=display;num=1163101573
miércoles, 10 de marzo de 2010
SQL - cómo separar las condiciones de join de las condiciones de negocio
Típica consulta:
En ella, el where mezcla condiciones de join (r.idregion=c.idregion) y de negocio (c.fechafundacion>='1810-01-01'):
En la sgte consulta, en el join+using aislamos las condiciones de join. En el where aislamos las condiciones de negocio:
SELECT r.nombre, c.nombre
FROM Region r, Ciudad c
WHERE r.idregion=c.idregion AND c.fechafundacion>='1810-01-01'
En ella, el where mezcla condiciones de join (r.idregion=c.idregion) y de negocio (c.fechafundacion>='1810-01-01'):
En la sgte consulta, en el join+using aislamos las condiciones de join. En el where aislamos las condiciones de negocio:
SELECT r.nombre, c.nombre
FROM Region r JOIN Ciudad c USING (idregion)
WHERE c.fechafundacion>='1810-01-01'
Suscribirse a:
Entradas (Atom)