cakephp-3.0

How to safely use reserved SQL names?

纵饮孤独 提交于 2019-11-26 12:33:26
问题 I\'m using Cakephp 3 using sqlserver as datasource server. I am sure there\'s no problem with my database connection.. as home.ctp prompts that I am connected to my database.. and I\'m as well using migrations plugin to create my tables.. it seems like there is no problem working with these tools. but after I bake my MVC, I only got page full of errors.. for example $bin\\cake bake all tests there are no errors I found and MVC are in its specific folder, testController.php, testTable, etc.

How to use different datasources in a Query using cakephp3?

◇◆丶佛笑我妖孽 提交于 2019-11-26 11:36:48
问题 I\'m working on a cakePHP3 project which does have 3 different datascources. I have one main model, called application, which should have two hasOne() associations to two models with a different datascource as Model Application. I have created the two models and pointed the two Model Tables to their datascources with defaultConnectionName() . Now I added two hasOne() relations to my ApplicationsTable object and recieve an sql error, when trying to Applications->get() . This is clear as in the

Encryption/Decryption of Form Fields in CakePHP 3

本秂侑毒 提交于 2019-11-26 11:27:57
问题 I want to have some form-fields encrypted when they are added/edited and decrypted when they are looked up by cake. Here is the code that works for me in v2.7.2: core.php Configure::write(\'Security.key\',\'secretkey\'); app/model/patient.php. public $encryptedFields = array(\'patient_surname\', \'patient_first_name\'); public function beforeSave($options = array()) { foreach($this->encryptedFields as $fieldName){ if(!empty($this->data[$this->alias][$fieldName])){ $this->data[$this->alias][

SQLSTATE[HY000] [1045] Access denied for user 'username'@'localhost' using CakePHP

送分小仙女□ 提交于 2019-11-26 09:03:03
问题 I am new to PHP and CakePHP. I am finding problems while wiring my database using CakePHP. Below is my application configuration. I am on Bitnami WAMP stack 5.4.40-0. I am using CakePHP 3.0.4 to create a web MVC application Entry for datasources in my app.php file. /** * Connection information used by the ORM to connect * to your application\'s datastores. * Drivers include Mysql Postgres Sqlite Sqlserver * See vendor\\cakephp\\cakephp\\src\\Database\\Driver for complete list */ \'Datasources

Cakephp-3.x: How to change the data type of a selected alias?

独自空忆成欢 提交于 2019-11-26 08:38:16
问题 WHen i try to do : $fields = array(\'id\' => \'custom_id\', \'title\' => \'some_name\'); The result I get has id as a string. If I do: $fields = array(\'custom_id\', \'title\' => \'some_name\'); then it gives custom_id as integer. How can I obtain custom_id as id without loosing the data type. I read the documentation but didn\'t found much help. There is something that virtual fields can do I think. But is it possible inside the find query without the use of virtual fields etc? Thanks in

CakePHP 3.0 -> Between find condition

非 Y 不嫁゛ 提交于 2019-11-26 06:45:55
问题 Is it possible to do a \"BETWEEN ? AND ?\" where condition LIKE in cakephp 2.5? In cakephp 2.5 I write something like \'conditions\' => [\'start_date BETWEEN ? AND ?\' => [\'2014-01-01\', \'2014-12-32\']] how can I migrate that? additionally I would write something like \'conditions\' => [ \'? BETWEEN start_date AND end_date\'] => \'2014-03-31\'] 回答1: Expressions Between expression are supported out of the box, however they only support the first case without additional fiddling: $Query =

Why are date/time values interpreted incorrectly when patching/saving?

僤鯓⒐⒋嵵緔 提交于 2019-11-26 04:55:47
问题 I try to save data from a cakephp 3 form. All data are well saved but datetime not. I\'ve got 2 datetime fields. Those fields are filled by jquery-ui widget. The problem seems to happened when pacthing entity. $intervention = $this->Interventions->patchEntity($intervention, $this->request->data); Debug of $this->request->data : \'user_id\' => \'1\', \'description\' => \'test\', \'starttime\' => \'2015/11/15 10:00\', \'endtime\' => \'2015/11/15 12:10\' Debug of my object $intervention after

How to limit contained associations per record/group?

岁酱吖の 提交于 2019-11-26 02:57:49
问题 I have a Model, Articles, which hasMany Abstracts. I want to load the 10 latest Articles, and for each Article, the Abstract with the highest number of points. My function looks like this: public function getArticles($category, $viewName) { $subArticles = $this->Articles->findByCategory($category)->contain([ \'Abstracts\' => function ($q) { return $q ->select([\'body\', \'points\', \'article_id\']) ->where([\'Abstracts.approved\' => true]) ->limit(10) ->order([\'Abstracts.points\' => \'DESC\'

How to filter by conditions for associated models?

早过忘川 提交于 2019-11-26 01:01:51
问题 I have a belongsToMany association on Users and Contacts. I would like to find the Contacts of the given User. I would need something like $this->Contacts->find()->contain([\'Users\' => [\'Users.id\' => 1]]); The cookbook speaks about giving conditions to contain, custom finder methods and sing through association key, but I did not find out how to put these together. 回答1: Use Query::matching() or Query::innerJoinWith() When querying from the Contacts table, then what you are looking for is

CakePHP 3.0 installation: intl extension missing from system

允我心安 提交于 2019-11-26 00:38:02
问题 Using the CakePHP docs, I am trying to install 3.0-beta2 using composer but I got this error: cakephp/cakephp 3.0.x-dev requires ext-intl * -> the requested PHP extension intl is missing from your system However, I know for sure that intl is installed (it shows on phpinfo). I\'m using PHP 5.4.33/Apache 2.4.10.1 回答1: I faced the same problem today. You need to enable the intl PHP extension in your PHP configuration ( .ini ). Solution Xampp (Windows) Open /xampp/php/php.ini Change ;extension