CakePHP makes building web applications simpler, faster and require less code.
See all
Members (4,046)
Megan Lalk's profile photo
James Watts's profile photo
Larry E. Masters's profile photo
kévin Lacire's profile photo
Aldo Saavedra Reyes's profile photo
Jeppe Borggaard Jørgensen's profile photo
Arkadiusz Wiertlewski's profile photo
Rodrigo Campos's profile photo
Syamil MJ's profile photo
Sergio Tafoya's profile photo
Arvind verma's profile photo
Musuda Alitsi's profile photo
Soinit Technology Solutions Pvt. Ltd.'s profile photo
Manuel Alejandro Marquez Ortiz's profile photo
Aussie Chuck's profile photo
Adèle Gareau's profile photo
kostali hassan's profile photo
Евгений Мальцев's profile photo
Autre planete's profile photo
Gopi Chand's profile photo
ko ko Kyaw's profile photo
jinaal patel's profile photo
Johnny Cash's profile photo
Adams Serrano Orellana's profile photo

Stream

Join this community to post or comment
 
I am proofreading my new CakePHP book: Learn CakePHP, With Unit Testing

It will be available soon at Apress: http://www.apress.com/9781484212134?gtmf=s

1
Add a comment...

Megan Lalk
moderator

Announcements  - 
 
 
Featured plugin of the week - An asset compression plugin for CakePHP #CakePHP #Opensource https://github.com/markstory/asset_compress
3
Add a comment...

Marco Nicolodi

CakePHP 3.x  - 
 
Arent these LIKE conditions vulnerable to SQL Injection?

I was looking in the documentation how to write a sql LIKE condition with the query builder, and ive found these two ways. Both of them look vulnerable to SQLinjection (as you concat strings with the '%' wildcard).

Are they really vulnerable? If they are, how can i write a sql LIKE condition with prepared statements using the ORM?

Here follows the queries ive found in the documentation:

$query = $articles->find() ->where(['title LIKE' => '%First%'])
//more code

$query = $cities->find()
->where(function ($exp, $q) {
          return $exp->like('name', '%A%');
});
1
Add a comment...
 
hi, i'm from costa rican and i was thinking make meetup of Cakephp developers. what is your opinions?
1
Add a comment...

Clement Crownrise

CakePHP 2.x  - 
 
I need a tutorial of how I can consume an API with CakePHP 2.8x.

Your help will be appreciated.

This is the api i want to integrate https://unplag.com/check-api/

Thanks
1
Add a comment...
 
Hello everyone,

Is it possible to set multiple default values on an input select box? I found that the attribute ''default' sets one default value, but what can be done about multiple values?My example here,

echo $this->Form->select('growthmed',$mediums,array('div' => false,
'label' => false,
'multiple' => true,
'default' =>'1ec310f3c88914c435be69c485ff48e2',
'empty' => [''=>'Select Medium...']));

The 'selected' attribute could be a solution? If yes, how should be the syntax?

Thanks.
1
Michael “Verblin” Christoglou's profile photo
 
finally i found it i had to put in the default an array with all the selected values
Add a comment...
 
Any suggestion for Cakephp 3 template engine ?
1
Fabio Sfuncia (fiblan)'s profile photo
 
CakePHP "View Templates" are OK!
But if you want use a good plugin for a good template engine try TwigView https://github.com/WyriHaximus/TwigView

Add a comment...

James Watts
moderator

Discussion  - 
 
With CakeFest 2016 here I put together some of my thoughts on #CakePHP - http://jameswatts.info/blog/thoughts-on-cakephp
1
Add a comment...
 
Hello,

Is there any way to implement the system as Symfony bundles:

To pack your own functions to distribute or reuse in other projects.

I think it's very important for structuring large software.

Thank you
1
hairo marin leiton's profile photoThodoris G.'s profile photo
6 comments
 
+Alexey Vasilev it is, but the question was about sf bundles and a cake plugin is a solution but not a bundle :-)
Add a comment...
 
Hello everybody,

I want to insert in my jointable(medium_unique) the same foreign keys but with different join data... How is it possible?
Now it saves a pair of the foreign keys only one time.

The jointable contains the following columns:
1)ATHUM_No (FK)
2)Medium_uuid (FK)
3)Phase (join data)
Also I do not use for the keys the _id naming , is still the "through" option valid?

Thank you in advance,

1
Alexey Vasilev's profile photoMichael “Verblin” Christoglou's profile photo
13 comments
 

Here is the function which collects the information (3 arrays) from three different select boxes. These data should be saved in the join table.

public function beforeSave($growthmed,$sporulationmed,$preservationmed,$athum)
{
$this-> loadModel('tmedium');
$i=0;
foreach ($growthmed as $value)
{
debug($value);
$this->request->data['tmedium'][$i]['Medium_uuid'] = $value;
$this->request->data['tmedium'][$i]['_joinData']['Phase'] = "Growth";
$i++;
}

foreach ($sporulationmed as $value)
{
debug($value);
$this->request->data['tmedium'][$i]['Medium_uuid'] = $value;

// $this->request->data['tmedium'][$i]['ATHUM_No'] = $athum;
$this->request->data['tmedium'][$i]['_joinData']['Phase'] = "Sporulation";
$i++;
}

foreach ($preservationmed as $value)
{
debug($value);
$this->request->data['tmedium'][$i]['Medium_uuid'] = $value;
$this->request->data['tmedium'][$i]['_joinData']['Phase'] = "Preservation";
$i++;
}
debug($this->request->data);

}


//and the add function


public function add()
{
$this->loadSelectValues();
$uniqueEntry = $this->UniqueEntries->newEntity();


if ($this->request->is('post'))
{
foreach ($this->request->data as $key => $value)
{
if ($value == '')
{
unset($this->request->data[$key]);
}
}
//arrays from three different input select boxes (input form)
$growth_mediums=$this->request->data['growthmed'];
$sporulation_mediums=$this->request->data['sporulationmed'];
$preservation_mediums=$this->request->data['preservationmed'];
$athum=$this->request->data['ATHUM_No'];
$this->beforeSave($growth_mediums,$sporulation_mediums,$preservation_mediums,$athum);
debug($uniqueEntry);

$uniqueEntry = $this->UniqueEntries->patchEntity($uniqueEntry,$this->request->data,
['associated' => ['tlifecyclestage','tecology','tproperties',
'tmedium','tpreservmeth','tenzymes','tmetabolites']]);
debug( $uniqueEntry);

if ($this->UniqueEntries->save($uniqueEntry, ['associated' => ['tlifecyclestage','tecology','tproperties',
'tmedium','tmedium','tpreservmeth','tenzymes','tmetabolites']]))
{
$this->Flash->success(__('The specimen/strain has been saved.'));
//debug($uniqueEntry);
return $this->redirect(['action' => 'index']);
}
else
{
$this->Flash->error(__('The specimen/strain could not be saved. Please, try again.'));
debug($uniqueEntry); die();
}

}
$this->set(compact('uniqueEntry'));
$this->set('_serialize', ['uniqueEntry']);

}

Is this enough or do you want whole file of controller? 
Add a comment...

Narendra Vaghela

CakePHP 3.x  - 
 
Just created a plugin for sending emails using Mailgun

http://narendravaghela.github.io/cakephp-mailgun/
CakePHP Mailgun. Mailgun plugin for CakePHP 3. View on GitHub Download .zip Download .tar.gz. MailgunEmail plugin for CakePHP. Build Status codecov.io Software License. This plugin provides email delivery using Mailgun. Requirements. This plugin has the following requirements: ...
1
Add a comment...
 
Hello everyone,
I am new in cakephp and I need your help :)

I have three tables: unique_entries, tlifecyclestage and the jointable of them lcs_uniqueentr

unique_entries has ATHUM_No as PK
tlifecyclestage has lcs_uuid as PK
lcs_uniqueentr has ATHUM_No & lcs_uuid as PK

I have set the following associations:

UniqueEntriesTable.php contains in initialize function
$this->belongsToMany('tlifecyclestage', [
'foreignKey' => 'lcs_uuid',
'targetForeignKey' => 'ATHUM_No',
'joinTable' => 'lcs_uniqueentr',
]);

TlifecyclestageTable.php contains in initialize function

$this->belongsToMany('unique_entries', [
'foreignKey' => 'ATHUM_No',
'targetForeignKey' => 'lcs_uuid',
'joinTable' => 'lcs_uniqueentr',]);


In add.ctp of unique_entries
echo $this->
Form>select('tlifecyclestage._ids',$lifecyclestages,array('div' => false,
'label' => false,
'multiple' => true,
'empty' =>[''=>'Select Stage...']));

UniqueEntriesController.php

$uniqueEntry = $this->UniqueEntries->patchEntity($uniqueEntry,$this->request->data,['associated' => ['tlifecyclestage']]);

$this->UniqueEntries->save($uniqueEntry)


Although the insert to the unique_entries is correctly formatted as | can see i the debug.log, the insert to the joinTable lcs_uniqueentr has not the correct values, particularly confuses the two foreign keys.

In reality I have the following data to insert
ATHUM_No =7
lcs_uuid =4


2016-05-19 19:02:19 Debug: INSERT INTO unique_entries (ATHUM_No, Coll_date, ISOL_date, DEP_date, DET_date, REDET_date, species_uuid, Phylum_uuid, Driedspeciment, Culturen, altDriedspeciment, altCulturen) VALUES (7, '', '', '', '', '', 'jif', 'de99076e462f1ccd7febcecd17a47ca9', 0, 0, 0, 0)

It is OK up to here..
But then , seems to have ATHUM_No as lcs_uuis and vice versa


2016-05-19 19:02:19 Debug: SELECT LcsUniqueentr.ATHUM_No AS `LcsUniqueentr__ATHUM_No`, LcsUniqueentr.lcs_uuid AS `LcsUniqueentr__lcs_uuid` FROM lcs_uniqueentr LcsUniqueentr WHERE (lcs_uuid = '7' AND ATHUM_No = 4)
2016-05-19 19:02:19 Debug: SELECT LcsUniqueentr.ATHUM_No AS `LcsUniqueentr__ATHUM_No`, LcsUniqueentr.lcs_uuid AS `LcsUniqueentr__lcs_uuid` FROM lcs_uniqueentr LcsUniqueentr WHERE lcs_uuid = '7'

2016-05-19 19:02:19 Debug: SELECT 1 AS `existing` FROM lcs_uniqueentr LcsUniqueentr WHERE (LcsUniqueentr.ATHUM_No = 4 AND LcsUniqueentr.lcs_uuid = '7') LIMIT 1


2016-05-19 19:02:19 Debug: INSERT INTO lcs_uniqueentr (ATHUM_No, lcs_uuid) VALUES (4, '7')



Do you know why is this happening? And how can it be fixed?

P.S
Notice that I cannot change the column names in database due to the fact that my client has already populated the database.





1
Michael “Verblin” Christoglou's profile photoAlexey Vasilev's profile photo
4 comments
 
No problems
Add a comment...

About this community

CakePHP makes building web applications simpler, faster and require less code.

Alan B

Discussion  - 
 
New dark theme for Netbeans 8.1 inspired by Atom.

http://blog.ajb.bz/2016/07/netbeans-dark-theme/
I love the Atom.io theme so I ported it over to Netbeans. Download the Theme
1
Add a comment...
 
How to call bake command from controller ?
I am looking for a way to create a plugin using bake plugin command from controller.
1
Add a comment...

Iván Amat

CakePHP 3.x  - 
 
Hello everyone. I just finished a plugin for CakePHP 3.x ACLs and I'm trying to make it installable via composer. The problem is that the plugin installs in the "vendors / ..." folder instead of in the "vendors /" folder. I have tried everything I found on the official website of composer and cakephp but I could not install the plugin in the "plugins" folder. Has anyone encountered the same problem and managed to fix it?



composer.json

{
"name": "ivanamat/cakephp3-aclmanager",
"description": "AclManager plugin for CakePHP 3.x",
"keywords": ["cakephp", "cakephp3", "cake3", "plugin", "acl", "manager"],
"homepage": "https://github.com/ivanamat/cakephp3-aclmanager",
"type": "cakephp-plugin",
"license": "MIT",
"authors": [
{
"name": "Ivan Amat",
"homepage": "http://www.ivanamat.es",
"role": "Author"
}
],
"require": {
"php": ">=5.4.16",
"composer/installers": "*",
"cakephp/cakephp": "~3.0"
},
"autoload": {
"psr-4": {
"AclManager\\": "plugins/AclManager/src"
}
},
"extra": {
"installer-name": "AclManager",
"installer-paths": {
"plugins/{$name}/": ["ivanamat/AclManager"]
}
},
"config" : {
"vendor-dir" : "plugins"
}
}

GitHub: https://github.com/ivanamat/cakephp3-aclmanager
Packagist: https://packagist.org/packages/ivanamat/cakephp3-aclmanager
1
Iván Amat's profile photo
 
Fixed: plugins installed by composer vendors are installed in the folder. You can see how the plugin is complete.

https://github.com/ivanamat/cakephp3-aclmanager
Add a comment...

Kingston Abraham

CakePHP 3.x  - 
 
Hosting provider doesnt support Php Intl extension, is there any way to run cakephp with plugins without causing any issues
1
Thodoris G.'s profile photoSean Wheller's profile photo
2 comments
 
Ditto
Add a comment...

Maxo Matos

CakePHP 3.x  - 
 
HI,

how to make this select "SELECT * FROM employees PARTITION (p1);"


Partition(p1) is problem.
1
Maxo Matos's profile photoFabio Sfuncia (fiblan)'s profile photo

Cao Vison

Announcements  - 
 
Is there chinese cakephp 3 user?
1
Fabio Sfuncia (fiblan)'s profile photoCao Vison's profile photo
2 comments
 
+Fabio Sfuncia 你不是么
 ·  Translate
Add a comment...

PABLO ASTORGA

CakePHP 3.x  - 
 
Hello greetings to all, I have a few months with this fantastic framework and design a small application I found a problem that is not solved, the program logic is as follows:
each airplane, a partner, engine and propeller have hours, when a flight is stored in the logs table is made, but when adding the hours must be added in parallel fomar the other tables. Do not know how it can be done. If I can help please
1
Deco F Martins's profile photo
4 comments
 
Update: As I was figuring out It works. Really, really easy to accomplish!

At your model, add a beforeMarshal() Method, in this method your data is still an array. You can just do all your logic here and populate back the array with the other table data. Example:

function beforeMarshal($event, $data, $options)
{
... your code
}

Your Array must follow Cake´s convention:

$data[
'main table data' => 'data',
...,
'relatedTableORM' => [
'related table data' => 'data',
],
];

Add a comment...

Jorge Arauz

Discussion  - 
 
 
Reality of Backend and Frontend Development
3
Add a comment...