Skip to content

Instantly share code, notes, and snippets.

View juniorb2ss's full-sized avatar
🎯
Focusing

Carlos E. Oliveira juniorb2ss

🎯
Focusing
View GitHub Profile
<?php
// Verficando se foi acionado o envio do formulário.
if(isset($_POST['submit']))
{
$login_digitado = $_POST['login'];
$senha = $_POST['senha'];
$nome = $_POST['nome'];
$email = $_POST['email'];
$telefone = $_POST['telefone'];
@juniorb2ss
juniorb2ss / gist:9133914
Created February 21, 2014 13:06
Datamapper object to array, with id as array key
/**
* Convert the entire $object->all array result set into an array of
* associative arrays.
* @see to_array
* @param DataMapper $object The DataMapper Object to convert
* @param array $fields Array of fields to include. If empty, includes all database columns.
* @param string $key_field Key Field array
* @return array An array of associative arrays.
*/
function all_to_array($object, $fields = '', $key_field = '')
/**
* Add or change flashdata, only available
* until the next request
*
* @access public
* @param mixed
* @param string
* @return void
*/
function set_flashdata($newdata = array(), $newval = '')
public function login()
{
// Caso o usuário já esteja logado, redireciona ele.
if($this->_needlogin(FALSE))
{
redirect('account');
}
// Exibe se existe mensagem pendente (notificação)
if($message = $this->session->flashdata('logout'))
<?php
$now = DateTime::createFromFormat('d/m/Y', '21/06/2014');
$tomorrow = DateTime::createFromFormat('d/m/Y', '22/06/2014');
var_dump($now == $tomorrow);
var_dump($now < $tomorrow);
var_dump($now > $tomorrow);
<?php
//INICIALIZA A SESSÃO
session_start();
$_SESSION["disciplinas"] = array(1 => 'curso 1', 2 => 'curso 2');
$_POST["disciplinas"] = array(3 => 'curso');
// Verifica se há chamadas de POST
if(!empty($_POST))
{
<?php
$arrayIdiomas = array('portugues' => 'idioma.portugues.php', 'english' => 'idioma.ingles.php', 'espanol' => 'idioma.espanhol.php', 'alemao' => 'idioma.alemao.php'); // definindo todos os idiomas disponiveis
// Definindo o idioma padrão
if(!isset($_SESSION['idIdioma'])){
$_SESSION['idIdioma'] = 'portugues';
}
if(isset($_REQUEST['idioma'])){
<?php
class Template {
private $words;
public function SetKeywords($Setkeyword, $Setvalue){
if(gettype($this->words) != 'array'){
$this->words = array();
}
$array = array($Setkeyword => $Setvalue);
$this->words = array_merge($array,$this->words);
<?php
namespace App\Modules\News\Models;
use Carbon\Carbon, Model\Category, Model\Tags, Model\Categorys, Debugbar;
class News extends \Eloquent {
public $with = [ 'tags', 'category' ]; // related relationship
<?php
$client = new SoapClient('http://www.url.com.br/ws.asmx?WSDL'); // URL de chamada.
$function = 'cep'; // qual função você quer trabalhar? No manual do webservice escolhido será disponibilizado a lista de todas.
// Aqui você define os argumentos que deseja enviar para a chamada. Por exemplo caso eu estivesse utilizando um WS do correiros, e desejasse retornar CEP.
$arguments= array('cep' => array(
'uf' => 'sp',
'cidade' => 'borba'
));