Skip to content

Instantly share code, notes, and snippets.

View rsocarras's full-sized avatar
🏠
Working from home

Rafael Socarras rsocarras

🏠
Working from home
View GitHub Profile
@rsocarras
rsocarras / mysql-php-mac-os
Created September 5, 2014 05:38
Instalar Mysql php MAC OS
sudo ln -s /private/tmp/mysql.sock /var/mysql/mysql.sock
@rsocarras
rsocarras / checkAccess_auth
Last active August 29, 2015 14:02
checkAccess Auth de sistema de Autenticación y autorización en Yii
<?php
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view' actions
'actions'=>array('index','view'),
'users'=>array('@'),
),
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('create','update'),
@rsocarras
rsocarras / Command Yii App
Created November 10, 2013 01:06
Crear un nuevo comando en YII y que este conectado en la base de datos de la aplicación WEB.
//Primero en protectec/config/console.php
<?php
// This is the configuration for yiic console application.
// Any writable CConsoleApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Console Application',
@rsocarras
rsocarras / Labels o Badges en un TbDetailView
Created November 6, 2013 00:47
Labels o Badges en un TbDetailView en Yii Framework con Bootstrap
<?php
switch ($model->estado){
case 0:
$classes = 'label label-success';
$model->estado ="Por asignar Usuario";
break;
case 1:
$classes = 'label label-info' ;
$model->estado ="Por asignar Mer";
break;
@rsocarras
rsocarras / dropDownListRow YII
Created October 16, 2013 05:43
dropDownListRow, con campos personalizados
if ($mer) {
print_r($mer[0][mer]);
foreach ($mer as $it=>$a) {
$arr[$it]= $mer[$it][mer]." ".$mer[$it][nivelelectoral];
}
$options["class"] = 'span3'; // Le doy Clases de CSS a el Select Input
$options["empty"] = 'Seleccione MER'; // Genero un EMPTY field.
@rsocarras
rsocarras / gist:6844277
Created October 5, 2013 18:12
DatePicker en YII Con Bootstrap
<?php echo $form->datepickerRow($model, 'date_start',array('value'=>date('Y-m-d'),'prepend'=>'<i class="icon-calendar"></i>','options' => array(
'mode'=>'focus',
'format'=>'yyyy-mm-dd',
'showAnim' => 'slideDown',
'autoclose'=>true,
))); ?>
@rsocarras
rsocarras / gist:5962236
Created July 9, 2013 23:30
Consultas en MySQL con Union y otras funciones. Practicas
SELECT date(datecreate) as fecha, sum(qty) as totales, round(sum(total),2) as totalVendido
FROM `facture_items`
WHERE datecreate between '2013-06-1' and '2013-06-30'
GROUP BY date(datecreate);
select date(datecreate) as fecha, sum(qty) as totales, round(sum(total),2) as totalVendido
from facture_items
where datecreate between '2013-06-1' and '2013-06-30'
group by date(datecreate);
@rsocarras
rsocarras / gist:5962231
Created July 9, 2013 23:29
Sumar dias a Fechas
$fecha = date('Y-m-d');
$nuevafecha = strtotime ( '+2 day' , strtotime ( $fecha ) ) ;
$nuevafecha = date ( 'Y-m-d' , $nuevafecha );
echo $nuevafecha;
@rsocarras
rsocarras / Trigger on MySQL
Last active December 19, 2015 03:48
A trigger with other tables
DELIMITER $$
USE `Fragata`$$
CREATE
DEFINER=`root`@`localhost`
TRIGGER `Fragata`.`IN_PRODUCTS_PRICE`
AFTER INSERT ON `Fragata`.`products`
FOR EACH ROW
BEGIN