cakephp-3.0

Use PaginatorHelper in Cells CakePhp 3

。_饼干妹妹 提交于 2019-12-24 19:34:01
问题 Hi I'm trying to use Paginator within a Cell the Paginator works rigth but the PaginatorHelper in the Template of the cell just doesn't work. I'm using CakePhp 3.5 Here is my code src/View/Cell/FinderCell.php namespace App\View\Cell; use Cake\View\Cell; use Cake\Datasource\Paginator; class FinderCell extends Cell { public function display() { $this->loadModel('Pokemon'); $paginador = new Paginator(); $pokemons = $paginador->paginate( $this->Pokemon->find() ); $this->set(compact('pokemons'));

how to display all the users in table users to my subjects table in add.ctp view

删除回忆录丶 提交于 2019-12-24 19:00:06
问题 Here is my subjects add.ctp view <?= $this->Form->create($subject) ?> <fieldset> <legend><?= __('Add Subject') ?></legend> <?php echo $this->Form->input('math'); echo $this->Form->input('english'); echo $this->Form->input('history'); echo $this->Form->input('science'); ******this field will display all the users in drop down************* from users table ?> </fieldset> <?= $this->Form->button(__('Submit')) ?> <?= $this->Form->end() ?> ****UsersController.php **** public function index() {

CakePHP 3.0 - Virtual property missing on production server

帅比萌擦擦* 提交于 2019-12-24 17:09:35
问题 I have a strange issue with CakePHP 3.0 and virtual properties on our server. We have a Photo Entity with the following virtual property: protected function _getPath() { [...] return $path; // array with path for different photo sizes } On our development server (Ubuntu, Apache, PHP 5.5.9-1ubuntu4.6) everything works perfectly. On our production server (Linux, Apache, PHP 5.5.23) the site is working great, except that the virtual properties are missing in the data object. The photo entity is

Show dates in a custom format

两盒软妹~` 提交于 2019-12-24 11:28:04
问题 I'm using CakePHP 3.0.10 and I'm trying to use this date format dd/mm/yyyy everywhere in my application, instead of yyyy-mm-dd . I know from the documentation that I can use ini_set('intl.default_locale', 'it_IT'); setting in my bootstrap.php file to do most of the dirty work, but still I am obtaining dates in dd/mm/yy format, which is not good for me. Setting it to fr_FR returns the right format, but obviously I'm missing all the translations and it is just wrong anyway :) How can I override

Multiple identical entitiy relation

为君一笑 提交于 2019-12-24 08:47:19
问题 I've got a products , attributes , and product_attributes table. Each product can have multiple attributes and these relations were stored in product_attributes , so far so good. But a product can have the same attribute multiple times. I just only can link different attributes to a product. For example: Audi (product) has Wheel (attribute): Amount (joinData) = 2; Value (joinData) = "front"; And Audi (product) has Wheel (attribute): Amount (joinData) = 2; Value (joinData) = "rear"; Only the

query builder: IN clause with composite columns

倖福魔咒の 提交于 2019-12-24 06:13:14
问题 I need to create a IN conditions on multiple columns, like this ... WHERE (order_date, order_number) IN ( ('2016-03-11', 3455453), ('2016-03-18', 83545454), ('2016-06-17', 5354544) ) starting from an array like this: $orders = [ ['2016-03-11', 3455453], ['2016-03-18', 83545454], ['2016-06-17', 5354544] ]; using cake3 query builder. I tried with ->where(['(order_date, order_number) IN' => $orders]); but I get an error: Cannot convert value to string I know it's not hard to manually create the

query builder: IN clause with composite columns

假如想象 提交于 2019-12-24 06:12:36
问题 I need to create a IN conditions on multiple columns, like this ... WHERE (order_date, order_number) IN ( ('2016-03-11', 3455453), ('2016-03-18', 83545454), ('2016-06-17', 5354544) ) starting from an array like this: $orders = [ ['2016-03-11', 3455453], ['2016-03-18', 83545454], ['2016-06-17', 5354544] ]; using cake3 query builder. I tried with ->where(['(order_date, order_number) IN' => $orders]); but I get an error: Cannot convert value to string I know it's not hard to manually create the

Cakephp 3 paginator sort fields with translate behavior i18n

自闭症网瘾萝莉.ら 提交于 2019-12-24 04:54:09
问题 I have a Posts table with Translate behavior and I want to sort it by title on the table at index view. I can't sort by the fields that are translated because the field's don't actually exist on the database. They exist on the i18n table. This, as I explained above, doesn't work: $this->Paginator->sort('title'); $this->Paginator->sort('Posts_title_translation.content'); So, what I should do? What am I missing? Many Thanks! 回答1: The second variant should work once the field is being

How to implement INSERT ON DUPLICATE KEY UPDATE aka upsert in CakePHP 3?

核能气质少年 提交于 2019-12-24 03:38:06
问题 I am using CakePHP 3 and MySQL. I would like to implement a INSERT on DUPLICATE KEY UPDATE aka upsert query via CakePHP 3 model. Given the following table: +----+----------+-----+ | id | username | age | +----+----------+-----+ | 1 | admin | 33 | | 2 | Timmy | 17 | | 3 | Sally | 23 | +----+----------+-----+ where id is Primary Key and username is unique index When I have the following values awaiting to be upserted: Felicia, 27 Timmy, 71 I expect the following result after the upsert: +----+-

Cakephp 3.0 Login returns false every time

萝らか妹 提交于 2019-12-24 03:35:08
问题 I am trying to log in a user on my Cakephp 3.0 site. My table has a 'username' and 'password' field, named as is. I can add a user and my password is successfully getting hashed and stored in my table. Despite this, I am unable to log in even once. My AppController initialize() method: $this->loadComponent('Auth',['loginAction' => [ 'controller' => 'ShopOwners', 'action' => 'login' ],'authenticate' => [ 'Form' => [ 'fields' => [ 'username' => 'username', 'password' => 'password', ],