cakephp-2.0

Instantiating a vendor class in class constructor

匆匆过客 提交于 2019-12-02 09:27:22
In my CakePHP 2 application I have such vendor. I need to create an instance of this vendor class inside my controller class. So I will use that instance inside my controller's different functions. App::import('Vendor', 'fancyVendor', array('file' => 'fancyVendor.php')); class MyController extends AppController { public $fancyVendor; function beforeFilter() { $fancyVendor = new fancyVendor(); $fancyVendor->setValue("12"); } function showMe() { echo $fancyVendor->getValue(); } } Inside my showMe function, I can't get the value that I set inside my beforeFilter function. Is there a proper way to

Connecting cakephp 2.0 with PostgreSQL

佐手、 提交于 2019-12-02 08:58:36
I am using cakephp 2.0 and a wamp server. I have enabled the pdo of postgres in the php and i tried connecting to Postgres. However it still says that there is an error. My login and password is also double confirmed. Below is codes for the database.php file: public $default = array( 'datasource' => 'Database/Postgres', 'persistent' => false, 'host' => 'localhost', 'port' => '5432', 'login' => 'postgres', 'password' => 'password', 'database' => 'Test', 'schema' => '', 'prefix' => '', 'encoding' => '' ); I even tried this: public $default = array( 'datasource' => 'Database/Postgres',

Caching plugin and normal controllers with duplicate names

寵の児 提交于 2019-12-02 08:48:45
I'm running into a problem related to caching, plugins and duplicate model names in Cake 2.0. My application has several controllers containing only actions for public use (view, index and equivalents). The data is managed by a CMS which is added as a plugin, some names of the plugin's controller are the same. For example, I have a PostsController in my application and a PostsController for the plugin. The plugin controller extends PluginAppController and the public controller extends AppController as per the manual. As soon as caching is kicked in (by setting debug to 0 ) the problems start.

Cakephp add function if id exists edit else create

泪湿孤枕 提交于 2019-12-02 08:48:06
I'm using cakephp 2 in my controller add function, I want to edit the data if the id exists, if not exists create. This is my code in add function: public function add () { if(!$this->request->data){ throw new NotFoundException(); } $googleCategory = $this->request->data; foreach ($googleCategory as $key => $value) { if(empty($value['category'])){ unset($value); } $conditions = array ( 'AccountShopMeta.shop_id' => $value['shop_id'], 'AccountShopMeta.name' => $value['category'], 'AccountShopMeta.value' => $value['url_key'] ); if(!$this->AccountShopMeta->hasAny($conditions)){ $this-

CakePHP- cakeDC search plugin implementation

三世轮回 提交于 2019-12-02 08:44:05
I am currently trying to figure out a way to implement cakeDC's search plugin within my application, but I am finding it quite difficult to understand the plumbing that needs to be done before I can get it to work(nicely) with my app. Things to consider: the search needs to be a 'live search' Records retrieved need to be paginated The search will be done using a selected criteria (id,name,etc the actual key not value) and will require a user entry which we will call 'query' for now.. here is my code so far. Model Code : public $filterArgs = array( 'query' => array('type' => 'query', 'method' =

Can i hide controller and view name cake php 2?

戏子无情 提交于 2019-12-02 08:38:38
问题 I am using cake php and due to some reason i want to hide controller and action name from the url . current url us like http://192.168.1.31/home/this_is_test where home is controller name and this_is_test is slug which is dynamic . i want the url like http://192.168.1.31/this_is_test. my routes.php is Router::connect('/', array('controller' => 'home', 'action' => 'index')); Router::connect('/dashboard', array('controller' => 'dashboard', 'action' => 'index')); Router::connect('/login', array(

Safe to use cakephp 3.0 for production?

北城余情 提交于 2019-12-02 06:03:27
We are starting a new project and it won't be done for 2-3 months. Should I build on version 3.0 since beta 3 was just released or continue with 2.5 and convert over when 3.0 stable is finally out? You will need to define what "safe" means to your standards. Safe as to security? I'd say pretty much yes. The project has 10 years on its back, potent programmers, several eyes that scrutinize it since early alphas, so I wouldn't expect anything major to slip there because of the beta status. Safe as to whether it's close enough to be coming out and not become vaporware? That's a definite yes. You

How to 'unlock' a field in a CakePHP form when it is part of a hasMany association

自闭症网瘾萝莉.ら 提交于 2019-12-02 05:59:00
问题 I have a form that represents a RewardModifier table in our database. That RewardModifier hasMany RewardOption . My form is structured like this (image): So, the RewardModifier can have many elements on the page, each with many RewardOption items. The Problem The problem is, that users can delete sections of this form using Javascript, which essentially removes it from the DOM. When they do that, it breaks the security component, because the POST'ed fields do not match the token supplied when

Avoid recording errors and debug logs on CakePHP 2

让人想犯罪 __ 提交于 2019-12-02 05:49:11
I am using an small hosting with only 200Mb of space and the error.log and debug.log files placed in "App/tmp/logs" are increasing in size very fast. Now their size is around 120Mb. I am using a cron job every 2 minutes and it could be the cause of it. I would like to disable the creation of both logs. How can I do it? The actual solution is to fix the errors and remove the debugging statements so that nothing would be written in the logs. To answer the question literally, you can configure the error handler to not log anything in core.php: Configure::write('Error', array( 'handler' =>

Can i hide controller and view name cake php 2?

爷,独闯天下 提交于 2019-12-02 05:30:38
I am using cake php and due to some reason i want to hide controller and action name from the url . current url us like http://192.168.1.31/home/this_is_test where home is controller name and this_is_test is slug which is dynamic . i want the url like http://192.168.1.31/this_is_test . my routes.php is Router::connect('/', array('controller' => 'home', 'action' => 'index')); Router::connect('/dashboard', array('controller' => 'dashboard', 'action' => 'index')); Router::connect('/login', array('controller' => 'users', 'action' => 'login')); Router::connect('/admin/login', array('controller' =>