Skip to content

Instantly share code, notes, and snippets.

@pokisin
Last active January 5, 2017 17:44
Show Gist options
  • Save pokisin/25556c8b90be4538cbb54c0eba8b1670 to your computer and use it in GitHub Desktop.
Save pokisin/25556c8b90be4538cbb54c0eba8b1670 to your computer and use it in GitHub Desktop.
Usar query personalizado en el modelo - Phalcon
<?php
use Phalcon\DI\FactoryDefault;
class Empresa extends \Phalcon\Mvc\Model
{
public static function getall(){
$query = "SELECT * from empresa";
$db = self::getConnection();
return $db->fetchAll($query, Phalcon\Db::FETCH_ASSOC);
}
public static function getConnection(){
$di = FactoryDefault::getDefault();
return $di->get('db');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment