Search Results

Sort by: Date / Title /

  1. 1 week ago by spirit
    Prevents jobs to collide if they take longer to run than the frequency itself
    1. $fp = fopen('/tmp/lock.txt', 'r+')
    2.  
    3. if(!flock($fp, LOCK_EX | LOCK_NB)) { 
    4.    echo 'Unable to obtain lock'
    5.    exit(-1)
    6. } 
    7.    
    8. /* ... */ 
    9.  
    10. fclose($fp);
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2040"></script>
  2. 1 week ago by spirit
    it's also possibl with a .htaccess file and "deny from all " in that file
    1. if (isset($_SERVER['REMOTE_ADDR'])) die('Permission denied.');
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2039"></script>
  3. 2 weeks ago by sx
    1. echo substr($filename, strripos($filename, '.'),strlen($filename));
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2038"></script>
  4. sponsorised links
  5. 3 months ago by macks
    1. //MenuCardTable.class
    2. public function getMenuCardForCombo(){
    3.         $q = Doctrine_Query::create()
    4.           ->select('m.*')
    5.           ->from('MenuCard m');
    6.         $results = $q->execute();
    7.  
    8.         foreach($results as $menu){
    9.             $choice[$menu->getId()] = $menu->getName();
    10.         }
    11.  
    12.         return $choice;
    13.     }
    14.  
    15. ====================no funciona para validar "required"=========================================
    16. //DishesForm.class
    17.         $choices = array('Seleccione un item') + Doctrine::getTable('MenuCard')->getMenuCardForCombo();
    18.         $this->widgetSchema['menu_card_id'] = new sfWidgetFormSelect(array('choices' => $choices));
    19.         $this->validatorSchema['menu_card_id'] = new sfValidatorChoice(array('choices' => array_keys($choices)));
    20.  
    21. ====================otro metodo: validar "required"=========================================
    22. //el item x defecto sera en blanco (poner 'add_empty true')
    23. //BasesDishesForm.class
    24. 'menu_card_id' => new sfWidgetFormDoctrineChoice(array('model' => 'MenuCard', 'add_empty' => true)),
    25. //DishesForm.class
    26. $this->validatorSchema['menu_card_id']->setOption('required', true);
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1897"></script>
  6. 3 months ago by macks
    1. Doctrine
    2. $eventName = Doctrine::getTable('Events')->find($id)->getName();
    3.  
    4. Propel
    5. $event = EventsPeer::RetriveByPk($id);
    6. $eventName = $event->getName();
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1896"></script>
  7. 4 months ago by macks
    1. /* lib/model/Industria.php
    2. - en el formulario de clientes hay un combo industrias (relacion bd)
    3. - descripcion se mostrara en el combo
    4. */
    5.  
    6. class Industria extends BaseIndustria {
    7.     public function __toString(){
    8.         return $this->getDescripcion();
    9.     }
    10. }
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1842"></script>
  8. 4 months ago by macks
    escapando y decodificando
    1. $specialCharacter = 'Fondo General de Contravalor Perú Japón - " FGCPJ "';
    2. $scape_decohtmlspecialchars(utf8_decode($specialCharacter));
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1840"></script>
  9. 4 months ago by macks
    recorriendo objetos decodificados del json
    1. <?php
    2. // arreglo
    3. $array['rows']= array('id_cuota' =>2883,'num_cuota' => 1,'monto_cuota' => 6250, 'fecha' => '2009-09', 'factura' => false);
    4. $array['rows']= array('id_cuota' =>2884,'num_cuota' => 2,'monto_cuota' => 6250, 'fecha' => '2009-09', 'factura' => true);
    5.  
    6. echo json_encode($array); //convirtiendo el arreglo en formato json
    7.  
    8. var data["rows"][{"id_cuota": 2883, "num_cuota": 1, "monto_cuota": 6250, "fecha": "2009-09", "factura": false}//var data['rows'] => variable referencia
    9.                     {"id_cuota": 2884, "num_cuota": 2, "monto_cuota": 6250, "fecha": "2009-09", "factura": true}]
    10.      
    11.  
    12. echo json_decode($data['rows']);
    13.  
    14. //decodificamos el json para convertirlo en un objeto
    15.   0 =>
    16.     object(stdClass)[178]
    17.       public 'id_cuota' => int 2887
    18.       public 'num_cuota' => int 1
    19.       public 'monto_cuota' => int 6250
    20.       public 'fecha' => string '2009-09' (length=7)
    21.       public 'factura' => boolean false
    22.   1 =>
    23.     object(stdClass)[179]
    24.       public 'id_cuota' => int 2888
    25.       public 'num_cuota' => int 2
    26.       public 'monto_cuota' => int 6250
    27.       public 'fecha' => string '2009-10' (length=7)
    28.       public 'factura' => boolean false
    29.  
    30.  
    31. //recorriendo y recuperando valores de un objeto
    32. foreach(json_decode($data['rows']) as $obj){
    33.         $idCuota = $obj->id_cuota;
    34.         $numCuota = $obj->num_cuota;
    35.         $monto = $obj->monto_cuota;
    36.         $fecha = $obj->fecha;
    37.         $factura = $obj->factura;
    38. } 
    39.  
    40. // yeah!!!!!!!
    41.  
    42. ?>
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1838"></script>
  10. 4 months ago by macks
    agrupar por un campo en comun y sumar por grupos y totales
    1. <?php
    2. //data inicial $data
    3. $data = array(array('CATE0001.Socio',10),array('CATE0001.Socio',5),array('CATE0004.Gerente',3),array('CATE0004.Gerente',20),array('CATE0006.Encargado',10));
    4.   var_dump($data);
    5.   0 =>
    6.     array
    7.       0 => string 'CATE0001.Socio'
    8.       1 => int 10
    9.   1 =>
    10.     array
    11.       0 => string 'CATE0001.Socio'
    12.       1 => int 5
    13.   2 =>
    14.     array
    15.       0 => string 'CATE0004.Gerente'
    16.       1 => int 3
    17.   3 =>
    18.     array
    19.       0 => string 'CATE0004.Gerente'
    20.       1 => int 20
    21.   4 =>
    22.     array
    23.       0 => string 'CATE0006.Encargado'
    24.       1 => int 10
    25.        
    26.        //agrupar por usuario  (cortar, solo el nombre)  -> dinamicamente
    27.       foreach($data as $i){
    28.           $catUser = explode(".",$i[0]);
    29.           $user = $catUser[1];
    30.           $group[$user][] = array(
    31.                     "gridGroupName"=>$user,
    32.                     "precio"=>$i[1]);
    33.       }
    34.  
    35.  
    36. /*
    37. * crear el array manualmente
    38. * $group['Socio'] = array(array('gridGroupName' => 'Socio','precio' => 10),array('gridGroupName' => 'Socio','precio' => 5));
    39.   $group['Gerente'] =array(array('gridGroupName' => 'Gerente','precio' =>20),array('gridGroupName' => 'Gerente','precio' => 3));
    40.   $group['Encargado'] = array(array('gridGroupName' => 'Encargado','precio' => 10)) ;
    41. */
    42. var_dump($group);
    43. //resultado de la grupacion == $group, del var_dump
    44.   'Socio' =>
    45.     array
    46.       0 =>
    47.         array
    48.           'gridGroupName' => string 'Socio'
    49.           'precio' => int 10
    50.       1 =>
    51.         array
    52.           'gridGroupName' => string 'Socio'
    53.           'precio' => int 5
    54.   'Gerente' =>
    55.     array
    56.       0 =>
    57.         array
    58.           'gridGroupName' => string 'Gerente'
    59.           'precio' => int 20
    60.       1 =>
    61.         array
    62.           'gridGroupName' => string 'Gerente'
    63.           'precio' => int 3
    64.   'Encargado' =>
    65.     array
    66.       0 =>
    67.         array         
    68.           'gridGroupName' => string 'Encargado'
    69.           'precio' => int 10
    70.  
    71. //sumar columnas - totales de reporte
    72. $precioFinal = 0;
    73. foreach($group as $k=> $i){
    74.     $precioGrupo = 0;
    75.     foreach($group[$k] as $r){
    76.         //acumulados
    77.         $precioGrupo += $r['precio'];                     
    78.        
    79.         //totales Finales
    80.         $precioFinal += $r['precio'];
    81.     }
    82.      
    83.    
    84.     $group[$k]['acumulados'] = array("precio"=>$precioGrupo);
    85. }
    86.  
    87. $group['TotalesFinales'] = array("precio"=>$precioFinal);
    88.  
    89. //nuevo array con los datos agregados (acumulados y totales finales)
    90. var_dump($group);
    91.   'Socio' =>
    92.     array
    93.       0 =>
    94.         array
    95.           'gridGroupName' => string 'Socio'
    96.           'precio' => int 10
    97.       1 =>
    98.         array
    99.           'gridGroupName' => string 'Socio'
    100.           'precio' => int 5       
    101.     'acumulados' =>
    102.         array
    103.           'precio' => int 15
    104.          
    105.   'Gerente' =>
    106.     array
    107.       0 =>
    108.         array
    109.           'gridGroupName' => string 'Gerente'
    110.           'precio' => int 20
    111.       1 =>
    112.         array
    113.           'gridGroupName' => string 'Gerente'
    114.           'precio' => int 3
    115.     'acumulados' =>
    116.         array
    117.           'precio' => int 23
    118.          
    119.   'Encargado' =>
    120.     array
    121.       0 =>
    122.         array         
    123.           'gridGroupName' => string 'Encargado'
    124.           'precio' => int 10
    125.     'acumulados' =>
    126.         array
    127.           'precio' => int 10
    128.          
    129. 'TotalesFinales' =>
    130.     array
    131.       'precio' => int 48
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1828"></script>
  11. 5 months ago by macks
    1. //desde la plantilla
    2. $sf_user->getUserId()$sf_user->getUserName();
    3.  
    4. //desde la accion de symfony
    5. $userId=sfContext::getInstance()->getUser()->getGuardUser()->getId();
    6. ó
    7. $usr = $this->getUser()//hallar el id si esta auntenticado
    8. if($usr->isAuthenticated()){
    9. $userId = $usr->getGuardUser()->getId();
    10. }
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1809"></script>

First / Previous / Next / Last / Page 1 of 13 (128 posteets)