cakephp

CakePHP 2.3: Save multiple forms in multiple tables all at once in 1 page

谁说我不能喝 提交于 2020-01-25 08:52:05
问题 I'm trying to set up a commercial proposal system using CakePHP 2.3. It has 5 tables which are associated (see details below). This system will have 1 page on which are 5 forms for each table. (see details below). Form 1: table proposals Form 2: table clients FK proposal_id Form 3: table products FK client_id Form 4: table specifications FK product_id (of the product) Form 5: table appendices FK product_id (of the product) WHERE: proposals hasOne clients. ----------v---------- clients

CakePHP - Model behaviours with variables

浪子不回头ぞ 提交于 2020-01-25 08:01:31
问题 I want two of my models to inherit a property and a couple of methods. I know I could put the methods in a behaviour but I'm not sure about the property. Can a behaviour have variables that are inherited by the model? Or should I just create another model that extends AppModel, and have the two models extend that one? 回答1: As long as both methods and variables are made public you can put your code into a behavior. In general I would go for a behavior, I guess. You could then create some

How do I call a helper function from a CakePHP component?

余生颓废 提交于 2020-01-25 01:45:10
问题 How do I call a helper function from a CakePHP component? 回答1: App::import('helper', 'Upload'); $test = new UploadHelper(); pr($test->hi()); 回答2: use this $this->controller->helpers[] = "helper name"; inside component class 来源: https://stackoverflow.com/questions/4944531/how-do-i-call-a-helper-function-from-a-cakephp-component

cakephp print a boolean

邮差的信 提交于 2020-01-24 22:01:05
问题 Beginners question in cakePHP, it drives me mad, I tried so much but can't get this working in cakePHP. I want to print 'Train station nearby' if the boolean is set. The database has the field 'train' bit(1) when doing a <?php echo h($property['Property']['train']); ?> it shows 1 but in the database it is 0, WHY is it printing 1 instead of 0 <?php if($property['Property']['train'] == true ) echo 'Train station nearby'; ?> This output works all the time, but of course it is not true! Anyone

cakephp print a boolean

点点圈 提交于 2020-01-24 22:00:26
问题 Beginners question in cakePHP, it drives me mad, I tried so much but can't get this working in cakePHP. I want to print 'Train station nearby' if the boolean is set. The database has the field 'train' bit(1) when doing a <?php echo h($property['Property']['train']); ?> it shows 1 but in the database it is 0, WHY is it printing 1 instead of 0 <?php if($property['Property']['train'] == true ) echo 'Train station nearby'; ?> This output works all the time, but of course it is not true! Anyone

CakePHP 3.5 Always apply asText() MySQL function to Spatial field

左心房为你撑大大i 提交于 2020-01-24 21:59:08
问题 I have a custom PolygonType which represents a POLYGON() field in a MySQL table. class PolygonType extends BaseType implements ExpressionTypeInterface { public function toPHP($value, Driver $d) { // $value is binary, requires unpack() } } I can use $query->func()->astext() on every find, but I would like to know if it's possible to always apply MySQL's AsText() function when selecting this field instead (similar to how toExpression() can be used when inserting data). 回答1: AFAIK there is no

CakePHP 3.5 Always apply asText() MySQL function to Spatial field

若如初见. 提交于 2020-01-24 21:58:06
问题 I have a custom PolygonType which represents a POLYGON() field in a MySQL table. class PolygonType extends BaseType implements ExpressionTypeInterface { public function toPHP($value, Driver $d) { // $value is binary, requires unpack() } } I can use $query->func()->astext() on every find, but I would like to know if it's possible to always apply MySQL's AsText() function when selecting this field instead (similar to how toExpression() can be used when inserting data). 回答1: AFAIK there is no

Error :The requested url /users/view is not found on this server

一笑奈何 提交于 2020-01-24 20:02:08
问题 I have installed the WAMP server in my windows machine .I have downloaded a simple cakephp application called "samplecake" from net and copy that application to c:WAMP/www And try to run the application using http:localhost/samplecake then it shows the login page (in routes.php i have redirected the '/' to users/login).In my controller the afterlogin redirect to /users/view , But after the successful login it will redirect to /users/view but it shows an error:Not Found The requested URL

Can we add custom values to a CakePHP Table Object?

风格不统一 提交于 2020-01-24 19:10:08
问题 I have a Cake Object when querying a table: $invoices = TableRegistry::get('invoices')->find('all', ['conditions' => ['order_number =' => $orderNumber]]); This works fine. I then want to add other array key/values to this Object, like this one: $invoicesTmp = array(); $invoicesTmp['customer'] = "name of customer"; But $invoicesTmp is incompatible with $invoices. (one is an array, other is an CakePHP Object) I have tried this: compact($invoices, $invoicesTmp); but that didn't worked. 回答1: The

Cakephp sharing auth between two applications

て烟熏妆下的殇ゞ 提交于 2020-01-24 16:39:05
问题 Is there an easy way to share login information between two cakephp apps on the same domain? Basically, MainApp has a full fledged user management suite, and I just want SecondaryApp to know if a visitor is logged in or not. 回答1: Make sure both applications are configured to handle the session the same way. In other words, we want both apps to read from the same cookie and we need both apps to look in the same location for that cookie. //app\config\core.php for both apps Configure::write(