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 | |
/** | |
* Permite validar a hora | |
* @param type $hora Hora no formato H:m | |
* @return boolean | |
*/ | |
function validarHora($hora) { | |
if (preg_match('/^[0-9]{2}:[0-9]{2}$/', $hora)) { | |
$horas = substr($hora, 0, 2); |
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
-- Vai Buscar todos os destritos | |
SELECT Distritos.CodigoDistrito AS 'Codigo Distrito', | |
Distritos.Designacao AS 'Distrito' | |
FROM gf_distritos; | |
-- Vai Buscar todos os concelhos coorespondentes a um determinado distrito | |
SELECT Concelhos.id AS 'Codigo Concelho', | |
Concelhos.Designacao AS 'Concelho', | |
FROM gf_concelhos | |
WHERE gf_concelhos.CodigoDistrito = 9; |
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
--Selecionar registo unico aleatório | |
SELECT * FROM table ORDER BY RAND() LIMIT 1 | |
--Remover registos com mais x dias | |
DELETE FROM tabela WHERE date < DATE_SUB(NOW(), INTERVAL X DAY); |
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
SELECT CURDATE(); | |
--Resultado: 2016-10-24 | |
SELECT CURDATE()+0; | |
--Resultado: 20161024 | |
SELECT DATE_ADD('2016-10-23 23:59:59', INTERVAL 1 DAY); | |
--Resultado: 2016-10-24 23:59 | |
SELECT DATEDIFF('2016-11-23 23:59:59','2016-10-31 23:59:59'); |
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
/** Carrega os distritos para o Dropdownlist */ | |
$.ajax({ | |
url:'<?=base_url('pedidos_ajax/getDistritos')?>', | |
type: 'post', | |
dataType:'json', | |
data: {<?= $this->security->get_csrf_token_name(); ?>:token_chave}, | |
success: function (resposta) { | |
var listaOpcoes= '<option value="" disabled selected>Escolha o Distrito</option>'; | |
var dadosJSON = resposta.dados; |
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
//Java scipt | |
var e = document.getElementById("ListaDistritos"); | |
var itemSelecionado = e.options[e.selectedIndex].value; | |
//JQuery | |
var itemSelecionado = $("#ListaDistritos").prop('selectedIndex'); |
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
$(function () { | |
//Config datepiker matrializecss () language | |
$('.datepicker').pickadate({ | |
selectMonths: true,//Creates a dropdown to control month | |
selectYears: 15,//Creates a dropdown of 15 years to control year | |
//The title label to use for the month nav buttons | |
labelMonthNext: 'Proximo Mês', | |
labelMonthPrev: 'Mês Anterior', | |
//The title label to use for the dropdown selectors | |
labelMonthSelect: 'Selecionar Mês', |
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
-- phpMyAdmin SQL Dump | |
-- version 4.6.4 | |
-- https://www.phpmyadmin.net/ | |
-- | |
-- Host: localhost:3306 | |
-- Generation Time: Oct 23, 2016 at 04:34 PM | |
-- Server version: 5.6.28 | |
-- PHP Version: 5.6.25 | |
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; |
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
//Opção 1 | |
window.location.href = "http://www.exemplo.com"; | |
//Opção 2 | |
window.location.assign("http://www.exemplo.com"); | |
//Opção 3 | |
window.open("http://www.exemplo.com"); |
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 | |
//Apaga ficheito | |
unlink("caminho/ficheiro.extenção"); | |
//Mover Ficheiro (Copiar e Elimina) | |
$origem = 'ficheiro.extenção'; | |
$destino = 'caminho/ficheiro.extenção'; | |
copy($origem, $destino); | |
unlink($origem); |