phalcon

How to get last insert id with Phalcon?

痞子三分冷 提交于 2019-12-20 00:42:58
问题 I tried using LAST_INSERT_ID() when getting the last id of the autoincrement primary key column but I get EOF exception : function add($tab) { $champs= ""; $value = ""; $separateur =""; $tab["commande_date"] = convertDateFormat5($tab["commande_date"]); foreach ($tab as $k => $v){ if ($k == "salle_code" || $k == "table_code") continue; $champs .= $separateur . $k; $value .= $separateur . "'" . $v . "'"; $separateur = ","; } $champs = '('.$champs.')'; $value = '('.$value.')'; $sSQL = " INSERT

How do I use “Main Layout” views in a multi module Phalcon application?

不想你离开。 提交于 2019-12-19 08:07:14
问题 I am using a "multi module" MVC structure for my PhalconPHP application. One issue I am trying to figure out is how I can configure my "Main Layout" view to be above the module view folders. In other words I want one master "Main Layout" (as described here) and I want all my modules to output their views at "Controller View" level within that main layout view. At default it appears the Main Layout view is being taken from [app] [module1] [controllers] [models] [views] (main layout is coming

How do I use “Main Layout” views in a multi module Phalcon application?

会有一股神秘感。 提交于 2019-12-19 08:07:07
问题 I am using a "multi module" MVC structure for my PhalconPHP application. One issue I am trying to figure out is how I can configure my "Main Layout" view to be above the module view folders. In other words I want one master "Main Layout" (as described here) and I want all my modules to output their views at "Controller View" level within that main layout view. At default it appears the Main Layout view is being taken from [app] [module1] [controllers] [models] [views] (main layout is coming

PhalconPHP MVC Micro app: Specify a request path and assert the response code

感情迁移 提交于 2019-12-18 09:13:55
问题 I've followed the unit testing tutorial and modified it to test a HTTP request to Micro MVC app, based on this post. I can successfully validate the output string, however I'm not sure how to assert the response status code or change the request path. index.php <?php $app = new \Phalcon\Mvc\Micro(); #Default handler for 404 $app->notFound(function () use ($app) { $app->response->setStatusCode(404, "Not Found")->sendHeaders(); }); $app->post('/api/robots', function() use ($app) { //Parse JSON

Error building : fatal error: pcre.h: No such file or directory

99封情书 提交于 2019-12-17 08:54:21
问题 I'm just finished installing Ubuntu 13.10. I want try Phalcon, and when I build the source (phalcon.so), I have this error : from /home/fabrice/Downloads/cphalcon/build/32bits/phalcon.c:204: /usr/include/php5/ext/pcre/php_pcre.h:29:18: fatal error: pcre.h: No such file or directory #include "pcre.h" ^ compilation terminated. make: *** [phalcon.lo] Erreur 1 My installation of lamp is : sudo apt-get install -y apache2 php5 mysql-server libapache2-mod-php5 php5-mysql php5-curl php5-imagick php5

Phalcon Model order by item popularity (number of appearances)

旧城冷巷雨未停 提交于 2019-12-13 03:56:02
问题 I'm sure I have done something like this before, but can't find it and google not being helpful. Using Phalcon model if possible, I want to select the items from a table whose ID appears the most - i.e. 10 most popular items ordered by popularity. Is this possible using Model::find("conditions") ? I do I have to use PHQL for this? 回答1: using model::find Model::find([ 'columns' => 'id,count(id) as counter', 'group' => 'id', 'order' => 'counter DESC' ]); PHQL: $this->modelsManager->executeQuery

How can I optimise COUNT with GROUPBY mysql query?

我的梦境 提交于 2019-12-13 03:55:58
问题 I have 5M records in eus table and 121 records in es table. I am doing a left join but the COUNT query is making my query very slow. How can I optimize this? public static function getAllActiveEvaluationSymptomsWithNameForDataTable(){ $queryBuilder = new Builder(); $queryBuilder ->from(array('es' => static::class)) ->leftJoin('EvaluationUserSymptom', 'es.id = eus.eb_evaluation_symptom_id','eus') ->columns('es.id, es.title, COUNT(eus.eb_evaluation_symptom_id) AS counts') ->groupBy('eus.eb

Phalcon - How do i do a SELECT IN Subquery with Phalcon models?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 01:47:50
问题 I need to know how to do i do a subquery type selection with phalcon models? for example i want to select all the users who viewed me, they are stored in the UserView table with columns 'id','user_from','user_to' (mapped by User table user_id to either user_from or user_to) so i want to select all the users who has a user_to as with the current user, and group by user_to make sure i only get one recorded, I wrote below function to do this but there is fundamental two problems 1. Is how to do

Is there some way to add an asset to every single page in Phalcon?

不羁的心 提交于 2019-12-13 00:45:59
问题 I am reading the documentation for Phalcon attempting to find a method of utilizing the Assets Manager to add CSS or JS files to every single page by default. I have been unsuccessful in finding any method of doing this. Adding an asset for an entire controller is easily accomplished by doing: public function initialize() { $this->assets->addCss('css/global.css'); } Is there some way I could add an asset to all controllers by default? The idea of overwritting the base controller class and

Phalcon router doesn't react to subfolders and namespace declaration

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 00:25:15
问题 So I've been reading a ton of stackoverflow and phalcon forum threads.. (I'm starting to hate this framework), but nothing seem to work and it doesn't explain why like Laravel does, for example. I'm just trying to be able to operate with this application structure: As you can see, all I want is to use namespaced controllers in subfolders to make more order for my code. According to all explanations, here's my loader.php: <?php $loader = new \Phalcon\Loader(); /** * We're a registering a set