作者:alevikz
项目:phres
/**
* @param Criteria $query
* @return HttpResponse
*/
public function response(Criteria $query)
{
if ($this->getPayload()->getOrder()) {
$query->orderBy($this->getPayload()->getOrderQuery());
}
$response = new CollectionResponsePayload($query, $this->createMeta($query));
return new HttpResponse($response);
}
作者:sergeytkachenk
项目:phalcon-rest-jp
/**
* @param string $preparedUrl
* @return null|string
*/
private static function buildWhere($preparedUrl)
{
$criteria = new Criteria();
$andList = explode('|', $preparedUrl);
$andList = array_filter($andList);
foreach ($andList as $condition) {
$criteria->andWhere(self::buildOR($condition));
}
return $criteria->getWhere();
}
作者:munozdanie
项目:sy
/**
* Searches for operadora
*/
public function searchAction($yacimientoId = null)
{
parent::importarJsTable();
$numberPage = 1;
if ($yacimientoId != null) {
$operadora = Operadora::find(array('operadora_yacimientoId=:yacimiento_id:', 'bind' => array('yacimiento_id' => $yacimientoId)));
} else {
if ($this->request->isPost()) {
$query = Criteria::fromInput($this->di, "Operadora", $_POST);
$this->persistent->parameters = $query->getParams();
} else {
$numberPage = $this->request->getQuery("page", "int");
}
$parameters = $this->persistent->parameters;
if (!is_array($parameters)) {
$parameters = array();
}
$parameters["order"] = "operadora_id";
$operadora = Operadora::find($parameters);
}
if (count($operadora) == 0) {
$this->flash->notice("No se han encontrado resultados");
return $this->dispatcher->forward(array("controller" => "operadora", "action" => "index"));
}
$paginator = new Paginator(array("data" => $operadora, "limit" => 25, "page" => $numberPage));
$this->view->page = $paginator->getPaginate();
}
作者:Jonhathan-Roda
项目:ranchogrand
/**
* Searches for usuario
*/
public function searchAction()
{
$numberPage = 1;
if ($this->request->isPost()) {
$query = Criteria::fromInput($this->di, "Usuario", $_POST);
$this->persistent->parameters = $query->getParams();
} else {
$numberPage = $this->request->getQuery("page", "int");
}
$parameters = $this->persistent->parameters;
if (!is_array($parameters)) {
$parameters = array();
}
$parameters["order"] = "idusuario";
$usuario = Usuario::find($parameters);
if (count($usuario) == 0) {
$this->flash->notice("The search did not find any usuario");
return $this->dispatcher->forward(array("controller" => "usuario", "action" => "index"));
}
$barcode = new Barcode();
echo "<style>";
echo $barcode->getCssStyle();
echo "</style>";
//echo $barcode->code39("AB20150wewesdsd");
$this->view->setVar("barcode", $barcode);
$paginator = new Paginator(array("data" => $usuario, "limit" => 10, "page" => $numberPage));
$this->view->page = $paginator->getPaginate();
}
作者:alawnche
项目:blog-tutoria
public function searchAction()
{
$numberPage = 1;
if ($this->request->isPost()) {
$query = Criteria::fromInput($this->di, "Categories", $_POST);
$this->session->conditions = $query->getConditions();
} else {
$numberPage = $this->request->getQuery("page", "int");
if ($numberPage <= 0) {
$numberPage = 1;
}
}
$parameters = array();
if ($this->session->conditions) {
$parameters["conditions"] = $this->session->conditions;
}
$parameters["order"] = "id";
$categories = Categories::find($parameters);
if (count($categories) == 0) {
$this->flash->notice("The search did not find any categories");
return $this->dispatcher->forward(array("controller" => "categories", "action" => "index"));
}
$paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => $categories, "limit" => 10, "page" => $numberPage));
$page = $paginator->getPaginate();
$this->view->setVar("page", $page);
}
作者:Jonhathan-Roda
项目:ranchogrand
/**
* Searches for vehiculo
*/
public function searchAction()
{
$numberPage = 1;
if ($this->request->isPost()) {
$query = Criteria::fromInput($this->di, "Vehiculo", $_POST);
$this->persistent->parameters = $query->getParams();
} else {
$numberPage = $this->request->getQuery("page", "int");
}
$parameters = $this->persistent->parameters;
if (!is_array($parameters)) {
$parameters = array();
}
$parameters["order"] = "idvehiculo";
$vehiculo = Vehiculo::find($parameters);
if (count($vehiculo) == 0) {
$this->flash->notice("The search did not find any vehiculo");
return $this->dispatcher->forward(array("controller" => "vehiculo", "action" => "index"));
}
foreach ($vehiculo as $v) {
//print_r($v->TiposVehiculo);
}
$paginator = new Paginator(array("data" => $vehiculo, "limit" => 10, "page" => $numberPage));
$this->view->page = $paginator->getPaginate();
}
作者:alexz20
项目:goldenligh
public function indexAction()
{
$nowurl = $this->request->getURI();
$type_list = $this->_getBusTypeList();
$this->view->type_list = $type_list;
$this->view->url = $nowurl;
$project_type = '';
$project_grow_up = '';
$is_type_belongs = false;
$numberPage = 1;
if ($this->request->isGet()) {
$query = Criteria::fromInput($this->di, "DtbProduct", $_GET);
} else {
$numberPage = $this->request->getQuery("page", "int");
}
$this->persistent->parameters = $query->getParams();
$parameters = $this->persistent->parameters;
if (!is_array($parameters)) {
$parameters = array();
}
$parameters["order"] = "product_id";
$dtb_product = DtbProduct::find($parameters);
if (count($dtb_product) == 0) {
$this->flash->notice("The search did not find any dtb_product");
}
$paginator = new Paginator(array("data" => $dtb_product, "limit" => $this->config->application->page_size, "page" => $numberPage));
$page = $paginator->getPaginate();
$page_split = $this->_split_page($page->current, $page->total_pages);
$this->view->page_split = $page_split;
//$this->view->disable();
$this->view->page = $page;
}
作者:esirona
项目:sandbox-
/**
* Searches for waypoints
*/
public function searchAction()
{
$numberPage = 1;
if ($this->request->isPost()) {
$query = Criteria::fromInput($this->di, "Waypoints", $_POST);
$this->persistent->parameters = $query->getParams();
} else {
$numberPage = $this->request->getQuery("page", "int");
if ($numberPage <= 0) {
$numberPage = 1;
}
}
$parameters = $this->persistent->parameters;
if (!is_array($parameters)) {
$parameters = array();
}
$parameters["order"] = "id";
$waypoints = Waypoints::find($parameters);
if (count($waypoints) == 0) {
$this->flash->notice("The search did not find any waypoints");
return $this->dispatcher->forward(array("controller" => "waypoints", "action" => "index"));
}
$paginator = new Paginator(array("data" => $waypoints, "limit" => 10, "page" => $numberPage));
$this->view->page = $paginator->getPaginate();
}
作者:w3yy
项目:phalph
/**
* list
*/
public function indexAction()
{
error_reporting(E_ALL & ~E_NOTICE);
//$this->persistent->parameters = null;
$numberPage = 1;
if ($this->request->isPost()) {
$query = Criteria::fromInput($this->di, "Topic", $_POST);
$this->persistent->parameters = $query->getParams();
} else {
$numberPage = $this->request->getQuery("page", "int");
}
if ($numberPage == null) {
$this->persistent->parameters = null;
}
$parameters = $this->persistent->parameters;
if (!is_array($parameters)) {
$parameters = array();
}
if ($this->request->getPost("topic")) {
$parameters["conditions"] .= " and topictype = 2 and status = 0";
//status:
} else {
$parameters["conditions"] = "topictype = 2 and status = 0";
//status:
}
//$parameters["order"] = "id";
$builder = $this->modelsManager->createBuilder()->columns('*')->from('Topic')->where($parameters['conditions'], $parameters['bind'])->orderBy('id');
$paginator = new PaginatorQueryBuilder(array("builder" => $builder, "limit" => 20, "page" => $numberPage));
$this->view->page = $paginator->getPaginate();
}
作者:munozdanie
项目:sy
/**
* Searches for equipopozo
*/
public function searchAction($yacimientoId = null)
{
parent::importarJsTable();
$numberPage = 1;
if ($yacimientoId != null) {
$equipopozo = Equipopozo::find(array('equipoPozo_yacimientoId=:yacimiento_id:', 'bind' => array('yacimiento_id' => $yacimientoId)));
} else {
if ($this->request->isPost()) {
//$query = parent::fromInput($this->di, 'Equipopozo', $this->request->getPost());
$query = Criteria::fromInput($this->di, "Equipopozo", $_POST);
$this->persistent->parameters = $query->getParams();
} else {
$numberPage = $this->request->getQuery("page", "int");
}
$parameters = $this->persistent->parameters;
if (!is_array($parameters)) {
$parameters = array();
}
$parameters["order"] = "equipoPozo_id";
$equipopozo = Equipopozo::find($parameters);
}
if (count($equipopozo) == 0) {
$this->flash->notice("No se encontraron resultados en la busqueda");
return $this->dispatcher->forward(array("controller" => "equipopozo", "action" => "index"));
}
$paginator = new Paginator(array("data" => $equipopozo, "limit" => 25, "page" => $numberPage));
$this->view->page = $paginator->getPaginate();
}
作者:devsnippe
项目:city_sit
public function indexAction()
{
$numberPage = 1;
if ($this->request->isPost()) {
$query = \Phalcon\Mvc\Model\Criteria::fromInput($this->di, "Models\\News", $_POST);
$query->order("id ASC, title ASC");
$this->persistent->searchParams = $query->getParams();
if (!\Helpers\Arr::is_array_empty($this->persistent->searchParams)) {
$news = \Models\News::find($this->persistent->searchParams);
}
} else {
$numberPage = $this->request->getQuery("page", "int");
if (!$numberPage or $numberPage <= 0) {
$numberPage = 1;
}
if ($numberPage > 1 and !\Helpers\Arr::is_array_empty($this->persistent->searchParams)) {
$news = \Models\News::find($this->persistent->searchParams);
} else {
$news = \Models\News::find();
$this->persistent->searchParams = null;
}
}
if (count($news) == 0) {
$this->flashSession->notice("Не найдено ни одной новости");
$this->persistent->searchParams = null;
}
$paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => $news, "limit" => 10, "page" => $numberPage));
$page = $paginator->getPaginate();
$this->view->setVar("page", $page);
$this->view->setVar('searchparams', $this->persistent->searchParams);
$this->view->setVar('numpage', $numberPage);
}
作者:munozdanie
项目:sy
/**
* Buscando las planillas.
* SI el usuario tiene rol de administrador podra ver todas las planillas.
* Sino se veran las Habilitadas unicamente
*/
public function searchAction()
{
parent::importarJsTable();
$numberPage = 1;
if ($this->request->isPost()) {
$query = Criteria::fromInput($this->di, "Planilla", $_POST);
$this->persistent->parameters = $query->getParams();
} else {
$numberPage = $this->request->getQuery("page", "int");
}
$parameters = $this->persistent->parameters;
if (!is_array($parameters)) {
$parameters = array();
}
$parameters["order"] = "planilla_id DESC";
$planilla = Planilla::find($parameters);
if (count($planilla) == 0) {
$this->flash->notice("No se encontraron resultados");
return $this->dispatcher->forward(array("controller" => "planilla", "action" => "index"));
}
$paginator = new Paginator(array("data" => $planilla, "limit" => 10000, "page" => $numberPage));
$this->view->page = $paginator->getPaginate();
$miSesion = $this->session->get('auth');
if ($miSesion['rol_nombre'] == 'ADMIN') {
$this->view->admin = 1;
} else {
$this->view->admin = 0;
}
}
作者:lookingatsk
项目:zhonghewanban
public function searchAction()
{
$numberPage = 1;
if ($this->request->isPost()) {
$query = Criteria::fromInput($this->di, "Companies", $_POST);
$this->persistent->searchParams = $query->getParams();
} else {
$numberPage = $this->request->getQuery("page", "int");
if ($numberPage <= 0) {
$numberPage = 1;
}
}
$parameters = array();
if ($this->persistent->searchParams) {
$parameters = $this->persistent->searchParams;
}
$companies = Department::find($parameters);
if (count($companies) == 0) {
$this->flash->notice("没有找到对应的部门");
return $this->forward("companies/index");
}
$paginator = new Phalcon\Paginator\Adapter\Model(array("data" => $companies, "limit" => 10, "page" => $numberPage));
$page = $paginator->getPaginate();
$this->view->setVar("page", $page);
$this->view->setVar("companies", $companies);
}
作者:Rho1and
项目:inv
public function searchAction()
{
$numberPage = 1;
if ($this->request->isPost()) {
$query = Criteria::fromInput($this->di, "Products", $_POST);
$this->persistent->searchParams = $query->getParams();
} else {
$numberPage = $this->request->getQuery("page", "int");
if ($numberPage <= 0) {
$numberPage = 1;
}
}
$parameters = array();
if ($this->persistent->searchParams) {
$parameters = $this->persistent->searchParams;
}
$products = Products::find($parameters);
if (count($products) == 0) {
$this->flash->notice("The search did not find any products");
return $this->forward("products/index");
}
$paginator = new Phalcon\Paginator\Adapter\Model(array("data" => $products, "limit" => 5, "page" => $numberPage));
$page = $paginator->getPaginate();
$this->view->setVar("page", $page);
}
作者:sr-hossein
项目:motorbik
/**
* Searches for motorbikes
*/
public function searchAction()
{
if ($this->request->isPost()) {
$query = Criteria::fromInput($this->di, "MotorBike\\Models\\Motorbikes", $this->request->getPost());
$this->persistent->parameters = $query->getParams();
}
return $this->listAction();
}
作者:riquedesimon
项目:bik
public function fromInput($modelName, $data)
{
if (!is_array($data)) {
throw new Exception("Input data must be an Array");
}
$conditions = array();
if (count($data)) {
$metaData = $this->getDI()->getShared('modelsMetadata');
$model = new $modelName();
$dataTypes = $metaData->getDataTypes($model);
$columnMap = $metaData->getReverseColumnMap($model);
$bind = array();
foreach ($data as $fieldName => $value) {
if (isset($columnMap[$fieldName])) {
$field = $columnMap[$fieldName];
} else {
continue;
}
if (isset($dataTypes[$field])) {
if (!is_null($value)) {
if ($value != '') {
$type = $dataTypes[$field];
if ($type == 2) {
$condition = $fieldName . " LIKE :" . $fieldName . ":";
$bind[$fieldName] = '%' . $value . '%';
} else {
$condition = $fieldName . ' = :' . $fieldName . ':';
$bind[$fieldName] = $value;
}
$conditions[] = $condition;
}
}
}
}
}
$criteria = new Criteria();
if (count($conditions)) {
$joinConditions = join(' AND ', $conditions);
$criteria->where($joinConditions);
$criteria->bind($bind);
}
return $criteria;
}
作者:sergeytkachenk
项目:angular-gulp-phalco
/**
* Searches for students
*/
public function searchAction()
{
$query = Criteria::fromInput($this->di, "Students", array_merge($_GET, $_POST));
$this->persistent->parameters = $query->getParams();
$parameters = $this->persistent->parameters;
if (!is_array($parameters)) {
$parameters = array();
}
$students = \Students::find($parameters)->toArray(true);
$this->view->disable();
$this->response->setContentType('application/json', 'UTF-8');
echo json_encode(array("student" => $students));
}
作者:sergeytkachenk
项目:angular-gulp-phalco
public function getPostsByDealerAction()
{
$query = Criteria::fromInput($this->di, "Dealers", array_merge($_GET, $_POST));
$this->persistent->parameters = $query->getParams();
$parameters = $this->persistent->parameters;
if (!is_array($parameters)) {
$parameters = array();
}
$posts = PostsService::getPostsByDealer($parameters);
$this->view->disable();
$this->response->setContentType('application/json', 'UTF-8');
echo json_encode($posts);
}
作者:sergeytkachenk
项目:angular-gulp-phalco
public function oneAction()
{
$query = Criteria::fromInput($this->di, "City", array_merge($_GET, $_POST));
$this->persistent->parameters = $query->getParams();
$parameters = $this->persistent->parameters;
if (!is_array($parameters)) {
$parameters = array();
}
$data = \City::findFirst($parameters)->toArray(true);
$this->view->disable();
$this->response->setContentType('application/json', 'UTF-8');
echo json_encode($data);
}
作者:codeceptio
项目:phalcon-dem
/**
* Search products based on current criteria
*/
public function searchAction()
{
$numberPage = 1;
if ($this->request->isPost()) {
$query = Criteria::fromInput($this->di, 'PhalconDemo\\Models\\Products', $this->request->getPost());
$this->persistent->set('searchParams', $query->getParams());
} else {
$numberPage = $this->request->getQuery("page", "int");
}
$parameters = $this->persistent->get('searchParams', []);
/** @var \Phalcon\Mvc\Model\Resultset\Simple $products */
$products = Products::find($parameters);
if (!$products->count()) {
$this->flash->notice("The search did not find any products");
return $this->forward("products/index");
}
$paginator = new Paginator(['data' => $products, 'limit' => 10, 'page' => $numberPage]);
$this->view->setVar('page', $paginator->getPaginate());
}