This file contains 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
// Comprobar si el fichero trae BOM | |
$bom = pack("CCC", 0xef, 0xbb, 0xbf); | |
if (0 == strncmp($json, $bom, 3)) { | |
$json = substr($json, 3); | |
} |
This file contains 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
function deleteDirectoryRecursive($dirPath) { | |
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirPath, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST) as $path) { | |
$path->isDir() ? rmdir($path->getPathname()) : unlink($path->getPathname()); | |
} | |
rmdir($dirPath); | |
} |
This file contains 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
-- Crear nuevo campo | |
ALTER TABLE `test` ADD COLUMN `ts_year_month` int(11); | |
-- Insertar valores en el campo para los registros actuales | |
UPDATE `test` SET ts_year_month = DATE_FORMAT(fecha,'%Y%m'); | |
-- Actualizar la definición de la nueva columna | |
ALTER TABLE `test` MODIFY `ts_year_month` int(11) NOT NULL; | |
-- Añadir el nuevo campo al índice |
This file contains 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
INSERT INTO clientes_peticiones ( | |
id_cliente,fecha,peticiones | |
) VALUES ( | |
1,'2011-11-02',1 | |
) ON DUPLICATE KEY UPDATE peticiones = peticiones+1; |
This file contains 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
// Supposing your want to be sure that $string is composed by valid UTF-8 characters: | |
$string = iconv("UTF-8","UTF-8//IGNORE",$string); | |
// If you want to remove none ISO-8859-1 characters from this string: | |
$string = iconv("UTF-8","ISO-8859-1//IGNORE",$string); | |
$string = iconv("ISO-8859-1","UTF-8",$string); | |
// If you still have characters you want to be ignored, try this: | |
$string = recode_string("us..flat", $string); |
This file contains 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
# La siguiente consulta añade un campo numerado a una consulta: | |
set @num=0; | |
select id, @num:=@num+1 AS contando FROM tabla; |
This file contains 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
REM Combinar los archivos js de un directorio | |
@echo off | |
pushd "%~1" | |
echo.>tmp.js | |
del tmp.js | |
for /r %%x in (*.js) do ( | |
type "%%~x" >> tmp.js | |
) | |
popd |
This file contains 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
Select * FROM pedidos_lineas | |
where id_pedido=33 | |
order by find_in_set(color, (SELECT GROUP_CONCAT(DISTINCT(color)) FROM pedidos_lineas WHERE id_pedido=33)); |
This file contains 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
UPDATE Hoja1 origen, clientes_acceso destino | |
SET destino.password = origen.NUEVA_CLAVE | |
WHERE destino.IDusuario = origen.CODIGO; |
This file contains 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_value date.timezone UTC |
OlderNewer