phalcon

Phalcon PHP: Modify a request URL before it gets dispatched

孤者浪人 提交于 2020-01-14 01:38:09
问题 I'm looking for a way to modify a request URL before it gets dispatched. For instance, the following URLs should be handled by the same controller/action: /en/paris /de/paris /paris I would like to capture the country code if it is present, then rewrite the URL without it so that controllers don't have to deal with it. I tried the 'dispatch:beforeDispatchLoop' event but it doesn't seam to be designed for that. Any idea? 回答1: If you can convention that all country code comes first in the path,

PhalconPHP: How to set a Selected option in SELECT tag

只愿长相守 提交于 2020-01-13 07:05:06
问题 I want to set the <option> with the value coming from Db. So far I tried this but not working: $site_select = new Select('site_id', $this->_sites); 回答1: Update Generating the select using DB columns as Timothy recommended: new Select('site_id', Sites::find(), array('using' => array('site_id', 'site_name'))); Setting the selected value of the given select: $site_select->setDefault('YOUR_DB_VALUE'); However there is another lovely trick about Phalcon forms. You could pass your DB entity to the

PhalconPHP: How to set a Selected option in SELECT tag

拈花ヽ惹草 提交于 2020-01-13 07:03:45
问题 I want to set the <option> with the value coming from Db. So far I tried this but not working: $site_select = new Select('site_id', $this->_sites); 回答1: Update Generating the select using DB columns as Timothy recommended: new Select('site_id', Sites::find(), array('using' => array('site_id', 'site_name'))); Setting the selected value of the given select: $site_select->setDefault('YOUR_DB_VALUE'); However there is another lovely trick about Phalcon forms. You could pass your DB entity to the

“Invalid Service Definition” when using DI->Get Phalcon PHP

无人久伴 提交于 2020-01-11 11:32:37
问题 This question is related to Appending multiple config arrays in PhalconPHP I am trying to get retrieve an object from the DI using the get method. The object is being set like this // $new_array the array with the merged data. Load it in a // \Phalcon\Config object $config = new \Phalcon\Config($new_array); //Store the config in your DI container for easier use $di->set('config', $config); And this is the error message I am getting when I call $new_array = $di->get('config'); [Uncaught

I can not query with like % in collection of phalcon

烈酒焚心 提交于 2020-01-05 06:34:21
问题 I use phalcon with mongo db. Model is Collection . I want use find to get SELECT * FROM Users WHERE Username LIKE '%TienNguyen%' I see in mongo db have query b.users.find( { Username: /TienNguyen/ } ) But in collection of Phalcon. How do I code it. I tried Users::find([['Username' => "/TienNguyen/"]]); It is not working. Please help me 回答1: As was mentioned above, regex searches that are not anchored at the beginning of the string can be very expensive because they require a full table scan.

I can not query with like % in collection of phalcon

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-05 06:33:32
问题 I use phalcon with mongo db. Model is Collection . I want use find to get SELECT * FROM Users WHERE Username LIKE '%TienNguyen%' I see in mongo db have query b.users.find( { Username: /TienNguyen/ } ) But in collection of Phalcon. How do I code it. I tried Users::find([['Username' => "/TienNguyen/"]]); It is not working. Please help me 回答1: As was mentioned above, regex searches that are not anchored at the beginning of the string can be very expensive because they require a full table scan.

Phalconphp routes not working

大憨熊 提交于 2020-01-04 06:06:26
问题 I'm new to phalconphp and following their tutorials, as far as I understand it, I don't need to create a specific routing component and that it should pick up a route if it exists. I could obviously be massively wrong here which means it should be easy to correct me! But so far the only controller that will work is my indexController. This is my bootstrap <?php try { //Register an autoloader $loader = new \Phalcon\Loader(); $loader->registerDirs(array( '../app/controllers/', '../app/models/'

Downgrade Phalcon from previous version?

橙三吉。 提交于 2020-01-03 17:25:14
问题 Im running in Ubuntu 15 and installed Phalcon v3 but i have an issue with our current working API which is using v2 of Phalcon, is there a way to downgrade the current version of Phalcon that i'd installed to the previous v2? 回答1: Usually, during compilation of Phalcon, you would execute this command. By default it will clone the master branch. git clone --depth=1 git://github.com/phalcon/cphalcon.git But to select a specific branch, you need to add the branch parameter to the end of your

Phalcon Multi module - Dynamic Module registration

白昼怎懂夜的黑 提交于 2020-01-02 10:08:17
问题 Hi guys Im using the following structure for a multi-module project in Phalcon [modules] [module1] [controllers] [models] [views] [module2] [controllers] [models] [views] [module-n] [controllers] [models] [views] I have registered only Module 1 and Module 2 in my bootstrap index.php file. Like this: $this->registerModules(array ( 'Module1' => array( 'className' => 'Modules\Module1\Module', 'path' => '../modules/module1/Module.php' ), 'Module2' => array( 'className' => 'Modules\Module2\Module'

How to connect multiple database in phalcon framework

荒凉一梦 提交于 2020-01-02 07:52:07
问题 i have to database namely master and xyz ,in that i required to connect both database in application . so is it possible to connect multiple database in one application and yes then how.? 回答1: Set your connections in DI: //This service returns a MySQL database $di->set('dbMaster', function() { return new \Phalcon\Db\Adapter\Pdo\Mysql(array( "host" => "localhost", "username" => "", "password" => "", "dbname" => "" )); }); //This service returns a PostgreSQL database $di->set('dbSlave',