Menu
  • HOME
  • TAGS

Cakephp MySql Query with WHERE

mysql,cakephp

You want to do something like this where $this->Session->read() returns the current authenticated user:- $this->Table->find( 'all', array( 'conditions' => array('Table.user_id' => $this->Session->read("Auth.User.id")) ) ); ...

CakePHP - Controller testing failed because of Security component

security,unit-testing,cakephp,cakephp-3.0

That is to be expected, as you're not sending the necessary security token, which is what the security component requires. Just look at your generated form, it will contain hidden inputs for the _Token field, with the subkeys fields and unlocked, where fields will contain a hash and possibly the...

Using slug in CakePHP v3

cakephp,cakephp-3.0

find() method returns a query object. Since you want the single entity that matches that slug, call first() on the query object: $article = $this->Articles->findBySlug($slug)->first(); ...

Radio Button CakePHP 3.0

php,cakephp,cakephp-3.0

You need to use FormHelper Templates. From migration guide: The separator, between, and legend options have been removed from radio(). You can use templates to change the wrapping HTML now. The div, before, after, between and errorMessage options have been removed from input(). so in your case use this echo...

Cakephp 3 and Postgre add.cpt doesnt work id_parent

postgresql,cakephp,cakephp-3.0

Either rename the view variable $parentMenus to $parents or in the view change echo $this->Form->input('parent_id'); to echo $this->Form->input('parent_id', ['options' => $parentMenus]); ...

Cakephp 2 : Have two different authentication functions

php,cakephp,authentication

i didn't understand your question . but i will it give blind shot anyway. i think you you want to support multiply cakephp auth. auth objects are they for that purpose. you can attach many objects and cakephp will check them sequentially , if any can identify the request, access...

how to call controllers from the cakephp default layout?

php,cakephp,cakephp-2.0

If you want all fields from logged user, you can use this in your view. $user = $this->Session->read('Auth.User')); This will return all storage data from users ( username, filename, all fields from user table) ...

ftp_get() does not download, instead moves file to website root folder

php,cakephp,ftp

You have a fundamental misunderstanding here: the "remote file" in an FTP connection is something remote from you - a file on another server somewhere, for instance. In your case, I think the file you're trying to serve is "local" in this sense, but you want a way of getting...

Retrieve records on matching a field in any 2 tables out of 4 tables

mysql,cakephp

This would return all the name values that appear in more than one table: select name from (select distinct name from table1 union all select distinct name from table2 union all select distinct name from table3 union all select distinct name from table4) temp group by name having count(*) >...

Basic CakePHP: Edit Post Method become Add Post Method

cakephp,methods,sql-update,edit

You're not using Cake's standard naming conventions so you need to make sure you override model attributes that Cake would normally auto-generate. Cake expects the primaryKey to be id which it uses to determine whether to insert or update a record. As you're using eventDate_id you need to tell Cake...

CakePHP 3.0 Auth Error Flash Element

php,cakephp,view,cakephp-3.0

As you've figured it's possible to configure the flash element when rendering it, to change this globally, configure the component instead. If all you want to do is to change the classname, then you can use the class parameter in the flash configuration options params setting: $this->loadComponent('Auth', [ // ......

intl PHP extension is not working for xampp server

php,cakephp

Once you have activated the php_intl.dll in the php.ini file you also need to copy the dll files that php_intl.dll uses from the PHP folder to the Apache/bin folder. I am not a XAMPP user so I am not sure of the actual folder names copy xampp/php/icu*.dll to xamp\apache\bin Also...

where I can find change log file in cakephp framework files?

php,cakephp,changelog

Cakephp doesn't have a changelog file in the repository. You can either browse trough the github versions for a short textual changelog: https://github.com/cakephp/cakephp/releases Alternatively you can read the changes in the cakephp news: http://cakephp.org/pages/news Or if you want see the granular changes you can browse the source code by tags:...

cakephp 3 order by query generates 14 queries with associate tables instead of 1

cakephp,cakephp-3.0

If you re-run the script immediately, you should see those queries disappearing. These queries are being used to grab data for generating schemas and other metadata, and by default this should happen rather rarely as the data is being cached, given that cacheMetadata is enabled in your apps datasource configuration....

Trouble linking models together in CakePHP2

php,cakephp,cakephp-2.6

From what you've described your associations look wrong. They should be something like:- User <?php class User extends AppModel { public $hasMany = array( 'Car' ); public $hasAndBelongsToMany = array( 'Address' ); } Car <?php class Car extends AppModel { public $belongsTo = array( 'User' ); public $hasAndBelongsToMany = array(...

Checking for 'isUniqueUsername' in cakephp doesn't seem to work?

php,cakephp,registration

Change 'unique' => array( 'rule' => array('isUniqueUsername'), 'message' => 'This username is already in use' ) To 'unique' => array( 'rule' => 'isUnique', 'message' => 'This username is already in use' ) You do not need that function to check for uniqueness, Cake does it for you with magic....

Best rules to get data with Contain

cakephp,cakephp-3.0

$articles = $this->Model->find() ->select(['fields_you_want_from_this_Model']) ->contain(['Assoc_Model' => function($q) { return $q ->select(['fields_you_want_from_the_associated_model']); }]); ...

PHP Multiple cURL requests to REST API stalls

php,rest,cakephp,curl

if you allowed to use external PHP libraries; I'd like to suggest this method: https://github.com/php-curl-class/php-curl-class // Requests in parallel with callback functions. $multi_curl = new MultiCurl(); $multi_curl->success(function($instance) { echo 'call to "' . $instance->url . '" was successful.' . "\n"; echo 'response: ' . $instance->response . "\n"; }); $multi_curl->error(function($instance) {...

Difference of cakephp2 and Cakephp3 [closed]

cakephp

Better performance : Version 3 incorporates performance improvements to the bootstrap process, the routing process, and several parts of process for generating helper templates. Enhanced components and helpers: Version 3 provides enhanced support for “flash messages” with its new FlashHelper and FlashComponent. In addition, the CookieComponent has been enhanced,...

Array to string conversion [CORE\Cake\Model\Datasource\DboSource.php, line 2094]

php,cakephp

The query you are hitting is not correct,try this:- $this->Product->updateAll(array('Product.rating' => "'".$this->request->data['Product']['rating']."'",'Product.review' => "'".$this->request->data['Product']['review']."'"),array('conditions'=>array('Pr‌​oduct.id' => $prod_id))); Note:- )of first array is misplaced. it must be closed before condition array. in condition array it will be Product.id not prod_id....

How to change the message in buildRules [CakePHP 3]?

validation,cakephp,cakephp-3.0

When using that style of adding unique rules, you'll have to pass the message to the isUnique() calls second argument, ie $rules->add($rules->isUnique(['email'], 'Este email já encontra-se em uso.')); That is because you are technically creating nested callables this way ($rules->isUnique() creates one, and $rules->add() creates another one), and defining options...

How to Edit User CakePHP 3

cakephp,cakephp-3.0

If you need to have the ability to change the password in the edit form, then you'll have to make sure that it is being dropped before it is being marshalled in case no data is being provided. This can be achieved using the Model.beforeMarshal event in your Users table...

cakephp 3.0.x extending view?

php,cakephp,cakephp-3.0

Yes you can do this if you use View Elements. The best way to do this would be to create an Element template for the customers index template and then output this in both your Customers/index and Main/index templates like this:- // Output Template/Element/customers.ctp echo $this->Element('customers'); The Element template will...

Cakephp 3 - MissingDatasourceConfigException when running phpunit test

php,unit-testing,cakephp,phpunit,cakephp-3.0

The problem was in the Command prompt, when I run my tests in Windows PowerShell everything was OK.

CakePHP Missing out AND statement on Query

php,mysql,cakephp

Your OR array is not correctly defined. You have created an array with 3 identical keys (i.e., the 'AND') Instead of this: 'OR' =>array( 'AND' => array( 'Event.start >=' => $search_from, 'Event.end <=' => $search_to), 'AND' =>array( 'Event.end >' => $search_from, 'Event.end <=' => $search_to), 'AND' =>array( 'Event.start >=' =>...

How to use: $this->Auth->user('id') in a model? Cakephp 3.0

cakephp,authentication,model,cakephp-3.0

What other way is there to get the id from the authenticated user in a model? Simply pass it to a model method: public function someModelMethod($userId, array $postData) { // Do something here, move your code from the controller here return $something; } public function someControllerAction() { $this->set('data', $this->Model->someModelMethod(...

Cake PHP change value of hidden form item by javascript

javascript,php,cakephp

This would have probably been a comment, but since I don't have enough reputation... I guess you are trying to change/assign the value to hidden field on a particular, action. I just assume a click event. Jquery required $('.classNameOfClickableObjt').clilck(function(){ $('input[name="data[Message][parent_id]"]').val(parentid); /*Another alternative, you might assign attribute, like $('input[name="data[Message][parent_id]"]').attr('value', parentid); */...

make SQL function SUBSTRING_INDEX work in cakePHP query builder

cakephp,cakephp-3.0

You can use raw expressions instead In your case there's no need to use the function builder, as you're passing safe, hardcoded values that don't need to be inserted into the query as bound parameters. You could instead simply use a raw expression like $query->newExpr('SUBSTRING_INDEX(`name`, "", -1)') - Arbitrary functions...

Cakephp: How to use migration to insert records

php,sql,cakephp,cakephp-3.0

CakePHP 3's Migration plugin is a Phinx wrapper plugin, so adding records can be done using the up() method:- public function up() { // Save records to the newly created schema } public function down() { // Remove records } For example, you could add a new user using TableRegistry...

Basic CakePHP: Unable to get the id (Edit Method)

cakephp,sql-update

Should be: echo $this->Form->create('EventDate'); // notice the capital CamelCase Side note: The info that displays in the fields will be out-of-date, since you 1) get the data from the DB and set to var, THEN do the save based on posted data. Another side note: There are quite a few...

Format displayValue option of find function with CakePHP 3.x

cakephp,cakephp-3.0

Take a look at virtual properties: http://book.cakephp.org/3.0/en/orm/entities.html#creating-virtual-properties. Looking at http://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#finding-key-value-pairs could say you can use virtual properties.

how to add normal script code to view.ctp in CakePHP 2.2.4

jquery,cakephp

Check if you have loaded jQuery in your layout (include it in the head of the document if you want it to work like this) It's $('#open'), not $('open'). Use jQuery selectors just like in css. ...

cant saveall on 1 model with cakephp

cakephp,cakephp-model

Sry to say this but your use of saveall is awkward. With save you usually want to create new records and don't specify an id field. So perhaps you get ploblems cause cakephp expects an update and one of the id's is already existent in the database. Btw. you can...

Disable password hashing for particular users

php,cakephp,cakephp-3.0

As has been pointed out serveral times to you in the comments you should never store passwords as plain text in your database. This is regardless to whether or not they are being directly used by your app or not. As Anthony mentioned in his comment to your question you...

CakePhp 2.6.3 Auth component not working. Accepting any userID/password combination

cakephp,cakephp-2.6

Good answer here : Cake PHP 2.4.x. AuthComponent login() always return true; Also read this : http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#identifying-users-and-logging-them-in...

postLink() in cakePHP 3.x

cakephp,hyperlink,delete

Did you use a proper IDE? Did you check the amount of attributes you may use for postLink()? The documentation clearly states: postLink($title, $url, $options). Why are you using a forth then? Of course that one will be ignored. So it should be this instead: $this->Form->postLink( "<i class='fa fa-remove'></i>", //...

Pagination in home.ctp not clickable data

cakephp,pagination

make the pagination data available in the element i.e $this->params['paging'] //index method if ($this->params['requested']) return array('images'=>$this->paginate('WebSite'), 'paging' => $this->params['paging']); $this->set('images', $this->paginate('WebSite') ); then in your home.ctp do this $images = $this->requestAction(array('controller'=>'websites','action'=>'index')); // if the 'paging' variable is populated, merge it with the already present paging variable in $this->params. This will...

How to Receive JSON sent from clent side to server Side in cakePHP 3.x

cakephp,cakephp-3.0

Check the docs, it's all well explained. Request::input() by default returns data in raw string format, if you need it to be converted, pass a callback to the method to handle that, for example json_decode. $this->request->input('json_decode'); See also Cookbook > Controllers > Request & Response Objects > XML or JSON...

conditions OR in join cakephp

php,mysql,cakephp

Build the conditions like - 'conditions' => array( 0 => array('View.id = UserView.view_id'), 1 => array('UserView.user_id' => $user_id), 3 => 'UserView.like => 1 OR UserView.like => 0' ), Or with using OR - 'conditions' => array( 0 => array('View.id = UserView.view_id'), 1 => array('UserView.user_id' => $user_id), 2 => 'UserView.like IN...

How can we validate multiple fields with one validation in cakePHP 2.0?

php,cakephp

You will want to setup a custom validation rule for testing that the 'full name' is unique. For example, in your model add a new method for validation like this:- public function validateUniqueFullName(array $data) { $conditions = array( 'first_name' => $this->data[$this->alias]['first_name'], 'last_name' => $this->data[$this->alias]['last_name'] ); if (!empty($this->id)) { // Make...

Remove resource wrapper from CakePHP REST API JSON

rest,cakephp,cakephp-2.2

Use the Hash utility to rewrite the results returned before setting the data for the View:- class LeadPostsController extends AppController { public $components = array('RequestHandler'); public function index() { $records = $this->LeadPost->find('all', ['limit' => 20]); $this->set(array( 'leadposts' => Hash::extract($records, '{n}.LeadPost'), '_serialize' => 'leadposts' )); } } Here Hash::extract($records, '{n}.LeadPost') will...

How to increase cakephp Auth component session expire time

php,cakephp,cakephp-3.0

Auth component shares Session class For Cakephp3 At config/app.php we can set the timeout. 'Session' => [ 'defaults' => 'php', 'timeout'=>24*60//in minutes ], For Cakephp2 in your Config/core.php Configure::write('Session', array( 'defaults' => 'php', 'timeout' => 31556926 //increase time in seconds )); ...

Cakephp Find all WHERE in two categories

php,cakephp,find,cakephp-2.3

I looked a little further on this and found the solution: To find all items, that belong to category.id 1 AND 2 (not OR) I just had to add a 'group' parameter to my find like this: $options['group'] = array('Item.id HAVING COUNT(DISTINCT Categorie.id) > 1'); The complete query (working): $kategories...

Moving a CakePHP 1.3.2 Application to a New Server

php,cakephp,cakephp-1.3

Your first error is because /home/SOME_NAME/public_html/OLD_DOMAIN_NAME/tmp/cache/ is not writeable. Make sure that tmp has the correct file permissions; it needs to be writeable by the web server user. Otherwise your issue appears to be that the database config is wrong so the app cannot connect to the database. Check app/config/database.php...

Validation Combobox CakePHP

php,mysql,validation,cakephp,cakephp-2.3

Maybe some custom validation like this: public $validate = array( 'someField1' => array( 'rule' => array('cantBeSame'), 'message' => 'someField1 cant be the same as someField2.' ), 'someField2' => array( 'rule' => array('cantBeSame'), 'message' => 'someField2 cant be the same as someField1.' ) ) public function cantBeSame(){ return ( $this->data['Somemodel']['someField1'] !=...

Access normal php file in cake php

php,.htaccess,cakephp

Normally If we need to use normal file in cakephp We need to store that file into the webroot folder of the cakephp. And the way to access is siteurl/filename.php Hope this will help you ...

Modify $this->request->data in model CakePHP?

php,cakephp,cakephp-2.6

$this->request->data cannot be accessed from within the model. This data is only accessible from the controller. When you attempt to save data to a model from the controller (e.g. $this->User->save($this->request->data))) you are setting the User model's data attribute. In other words, this is happening:- $this->User->data = $this->request->data; So in your...

can I consider GitHub Issue equals Number of Bugs for a project? [closed]

php,cakephp,github,frameworks

You assumption is wrong. You can put enhancements/feature requests in there as well.

How to implement pagination with search in CakePHP

cakephp,pagination,cakephp-2.0

i have got solution to my problem , here it is . I have used a code in view page , here $search variable i have setted data from controller. $search); $this->Paginator->options(array( 'url' => $urlParamAr )); echo $this->Paginator->prev('« Previous', null, null, array('class' => 'disabled')); echo $this->Paginator->numbers(array('first' => 'First page')); echo...

How to create a join table record

php,cakephp,cakephp-3.0

I've found that my mistake actually was in the newEntity() part! Before(Broken): $newEntity = $this->newEntity($inputData]); After(Fixed): $newEntity = $this->newEntity($inputData, ['associated' => ['Participants']]) And BEFORE executing newEntity I add the id's to the data list as following: $inputData['participants'] = [ '_ids' => [10, 12] ]; ...

how to display a message if database table is empty in cakephp

cakephp,cakephp-2.3

You used $this->set('results', $this->Application->find('all')); in your controller, and in your view you are looping with a different variable. "results" should be your variable in foreach as set in your controller. That's just by the way. To answer your question, you should use count. if(count($results) > 0){ //Do whatever u like...

How to Save Associated Table in CakePHP 3.0

cakephp,cakephp-3.0

Your array for your GoodStock association should be a lower-underscored version of the association name. Plus, it probably won't be a one-dimensional array thus it's a hasMany association. You can find more information here. So your code should be moreless as: $data = [ 'brand' => 'brand', 'name' => 'name',...

Cakephp link to view a page in sub folder

cakephp,cakephp-2.0,cakephp-2.3

If you want to genereate multiple path segments, then you have to pass them as separate values, like echo $this->Html->link('Tiny MCE plugin', array( 'controller' => 'pages', 'plugin' => false, 'action' => 'display', 'testtinymce', 'testtinymce', // ... )); See also Cookbook > Development > Routing > Passed Arguments...

CakePHP 3.0 IIS web.config

php,cakephp,iis,iis-7.5,cakephp-3.0

@ADmad helped me figure this out. It turns out that this had nothing to do with web.config in IIS. It isn't a CakePHP 3.0 specific thing either. According to CakePHP IRC the CakePHP 3.x and CakePHP 2.x routing is exactly the same. This is simply IIS PHP weirdness. The solution...

Sql date between query with a date and number of days

php,mysql,date,cakephp

strtotime will not recognize that expression. Do it with mysql - 'conditions'=>array( 'Renewal.NextRenewalDate <=' => 'DATE_ADD(NOW() + INTERVAL `Renewal`.`NextRenewalDate` DAY)' ) ...

HABTM CakePHP no results for related model

cakephp,cakephp-2.0,has-and-belongs-to-many

I think you're problem relates to the fact that you are not using CakePHP's naming conventions. From the look of the query being generated Cake doesn't know how to correctly alias the join table, hence getting an AppModel alias in your query. I suspect that this is causing issues when...

CakePHP find WHERE NOT EQUAL

php,cakephp,frameworks

Your conditions need to be ['Transaction.id' => $client_id, 'Transaction.name !=' => 'Facturation']. Multiple conditions of the conditions array are interpreted as 'AND' conditions. So your query would look like:- $transaction_query = $this->Transaction->find('all', [ 'limit' => $countList, 'fields' => [ 'Transaction.client_id', 'Transaction.name', 'Transaction.created', 'Transaction.message_id', 'Transaction.credit' ], 'conditions' => [ 'Transaction.id' =>...

cakephp 3 multi level associated save

cakephp,cakephp-3.0

I have found the solution. I have read the cookbook again and I noted in one of the examples snippets 'associated' => ['Tags', 'Comments.Users'] I have applied this to my controller and it now works. It is saving on all levels. $user = $this->Users->patchEntity($user, $this->request->data, [ 'associated' => ['Employees', 'Employees.Courses']...

Get last inserted ID after inserting to associated table

cakephp,cakephp-3.0

Table::save() returns the entity with updated ids. So store the return value in a variable and use appropriate property of the entity.

Different find results between cakephp 2.5 and 3.0

cakephp,cakephp-3.0

You are looking at custom formatted debug output, not a logical representation of the object (use for example var_dump() to see the difference). Until recently, when dumping an entity via debug(), various hidden properties were being made visible, including the $_properties property, which holds a map of the available properties...

CakePHP 2.x Sending user messages to element('menu')

cakephp,menu,message

For instance, once a user is logged in, I have to recover some informations about him. The User.id, User.name, etc. are recovered using the SessionHelper as follow : Not a good idea, the best is to set the user data from the auth component to the view. For example...

I need to count the today created account in Cake 3

cakephp,cakephp-3.0

What you are doing there won't work for various reasons. You cannot pass SQL snippets in the value part of the conditions array, it will be escaped and you'll end up with a string comparison like created = 'CURDATE()', you'd either have to pass the whole condition as a string,...

cakephp 3 bootstrap-ui change prev/next text

cakephp,cakephp-3.0,cakephp-bootstrap-ui

This appears to be badly documented, but to configure any of the settings for a helper you need to pass them as an array when you load it. So for example, if you are loading the Paginator helper inside your AppView you would pass prevlike this:- $this->loadHelper( 'Paginator', [ 'className'...

How to load a xml file in plugins webroot

cakephp,plugins,components,cakephp-3.0

You can use Plugin::path() to retrieve the absolute path to your plugin, so you don't have to hardcode it. Plugin::path('YourPlugin') . 'webroot' . DS . 'RangeMessage.xml' See also API > Cake\Core\Plugin::path()...

Cakephp select disable field value send failed

cakephp,scala-2.9

That's how HTML works, values of disabled elements are not being sent. Use a hidden field just like it would automatically be used for multiple type selects or checkboxes. It should have the same name as the actual field and be placed before it. That way the hidden value will...

File not Uploading using Ajax in cakephp

php,jquery,ajax,file,cakephp

With this AJAX form submission approach, you will not be able to upload file using ajax. If you don't like using a third-party plugin like dropzone.js or Jquery file upload, you can use XMLHttpRequest. An example below: $('#newcatform').on('submit', function(ev){ ev.preventDefault(); var forms = document.querySelector('form#newcatform'); var request = new XMLHttpRequest(); var...

CakePHP 3: change order in dateWidget

cakephp,cakephp-3.0

You can configure the DateWidget template when initializing the Form helper // in MyController.initialize() $this->loadHelper('Form', [ 'dateWidget' => '{{year}}{{month}}{{day}}{{hour}}{{minute}}{{second}}{{meridian}}' ]); or you can override the template using the templates function in the form component $this->Form->templates([ 'dateWidget' => '{{year}}{{month}}{{day}}{{hour}}{{minute}}{{second}}{{meridian}}' ]); @see http://book.cakephp.org/3.0/en/views/helpers/form.html#customizing-the-templates-formhelper-uses...

How to show associated data in add form in cakephp 3.x

cakephp,has-and-belongs-to-many,cakephp-3.0

You need to camelCase the View variable for the options for the magic to happen, so it should be $userRoles rather than $user_roles:- $this->set('userRoles', $this->Users->UserRoles->find('list', ['id', 'role_name'])); Cake will then know to associate the variable with the form field. Otherwise you will have to specify the variable used for the...

Cakephp3 query model

cakephp,cakephp-3.0

This is job for matching() method, which will create INNER JOIN with RefundProducts, so you will get only Products that have some RefundProducts. Conditions in contain limit only fetched associations $result = $this->Products->find() ->contain(['RefundProducts' => function ($q) use ($refund_condition) { return $q->where($refund_condition); }]) ->matching('RefundProducts') ->distinct(['Products.id']); I'm not sure what $refund_condition...

CakePHP - all pages blank except the home page

php,cakephp,cakephp-1.3

For me it looks like a problem with mod_rewrite, look on http://m.gratuito24.com/index.php/ads/index/showAds:goods/language:bg.html, index.php part is important, first thought: no mod_rewrite on server, second: something wrong with .htaccess...

how to add search by date cakePHP

cakephp,cakephp-2.5

Use BETWEEN: $conditions = array( 'Tapplicant.AppDate BETWEEN ? AND ?' => array( $start, $end, ) ); Read more about complex find conditions in CakePHP 2 here: http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#complex-find-conditions...

How to view a cakephp plugin page

php,cakephp,plugins,cakephp-2.0

As stated in the comments your code is correct, but you need a PagesController in your plugin. http://book.cakephp.org/2.0/en/plugins/how-to-create-plugins.html#plugin-views

CakePHP 3.x: hide shell class

shell,cakephp,cakephp-3.0

The available shells are being retrieved by scanning the shell folders for .php files. Exclusions are only made to the list of shells that live in the main app and the core (AppShell, CommandListShell and CompletionShell are being hidden by default), the plugin shell list is not going to be...

Get Google Plus Images Using Zend Framework 1 Gdata

php,cakephp,zend-framework,google-plus,gdata

Zend_Gdata uses ClientLogin which was deprecated as of April 20, 2012 and turned off on May 26 2015. This code will not longer work you need to switch to using Oauth2. You can use the current Google PHP client library to authenticate then use the access token created there to...

Set data from database to generated popup window in CakePHP

cakephp

first create a view for your controller action. the view file name has to be conventionally named i.e underscored version of the cooresponding controller action e.g if you have action named viewArticle the view file w'd be view_article.ctp public function viewArticle(){ $data = $this->{$this->modelClass}->find('all',$conditions); // here set your data to...

Cakephp 3.x Ajax deleting data gives this Error: Unknown method “isNew”

php,ajax,cakephp,cakephp-3.0

You are passing a query object to Table::delete(), that's not how it works, the method expects an entity, which you have to fetch in beforehand. Simplified example $this->delete($this->get($id)); See also Cookbook > Database Access & ORM > Deleting Data Cookbook > ... ORM > Retrieving Data ... > Getting a...

Change language in CakePHP

php,cakephp

Cake php proivide a very nice way to execute function without being login into the system. that is $this->Auth->allow() in AppController. So In App controller you will get this line $this->Auth->allow() somewhere. in that just give those action names which are going to change language . that functions starts working...

print_r on array set in view on cake just prints 'Array'

php,arrays,cakephp

Remove double quote from $this->set('messages', "$messages"); it should be $messages = array("Apples", "Oranges", "Pears"); $this->set('messages', $messages); and in view you can <?php pr($messages); ?> ...

describe( ) in CakePHP 3.x

cakephp,cakephp-3.0

Maybe this could help you? http://api.cakephp.org/3.0/class-Cake.Database.Schema.Collection.html#_describe It seems to be the samen functionality......

Different cakephp datasource for local and live

cakephp,cakephp-3.0

In boostrap or in App Controller, paste this if(Configure::read('debug')){ ConnectionManager::config('deployment'); } this change the default config of database when the debug is true....

CakePHP 2.6.0 is not loading CSS and JS files

css,.htaccess,cakephp,mod-rewrite,cakephp-2.6

I solved my problem, the solution is firstly (in my case) delete the three .htaccess files and edit this line in app/config/core.php //Configure::write('App.baseUrl', env('SCRIPT_NAME')); to this: Configure::write('App.baseUrl', env('SCRIPT_NAME')); it works for me, thanks guys anyway....

Changing the order items are retrieved from the DB in CakePHP?

php,cakephp

Something like this should do it: public $hasMany = array( 'Post' => array( 'className' => 'Post', 'foreignKey' => 'forum_id', 'dependent' => false, 'order' => 'Post.created ASC' //order the Posts in ascending order based on whe they were created ) Assuming you have a created column in your database table. Edit:...

issue Login cakephp

cakephp,login

Add the userModel setting to use a model other than 'User' for your login/users: 'authenticate' => array( 'Form' => array( 'passwordHasher' => 'Blowfish', 'userModel' => 'QuanTriVien' // <-- ADD THIS ) ) Details here....

Uploading image in cakephp and storing it's path in database

php,cakephp

In Your Controller if ($this->request->is('post')) { $this->OlxProduct>create(); if(!empty($this->data)) { //Check if image has been uploaded if(!empty($this->data['OlxProduct']['image_field_name']['name'])) { $file = $this->data['OlxProduct']['image_field_name']; //put the data into a var for easy use $ext = substr(strtolower(strrchr($file['name'], '.')), 1); //get the extension $arr_ext = array('jpg', 'jpeg', 'gif'); //set allowed extensions if(in_array($ext, $arr_ext)) { //do the...

Cakephp Version 2.x Unable to Show selected file name in edit view

php,cakephp,file-io,editview

The Problem: According to the CakePHP 2.0 book: Due to the limitations of HTML itself, it is not possible to put default values into input fields of type ‘file’. Each time the form is displayed, the value inside will be empty. While I'm sure there are ways you could hack...

CakePHP 1.3 - Extract URL GET parameters

php,url,cakephp,get,cakephp-1.3

From the Cakephp 1.3 book: URL: /contents/view/chapter:models/section:associations Mapping: ContentsController->view(); $this->passedArgs['chapter'] = 'models'; $this->passedArgs['section'] = 'associations'; $this->params['named']['chapter'] = 'models'; $this->params['named']['section'] = 'associations'; So you should use: $this->params['named']['name1'] $this->params['named']['name2'] ...

on editing file upload field is blank

image,cakephp

There's no way to do this. See related question: Dynamically set value of a file input. Most browsers block against setting the value attribute on input type file for security reasons so that you can't upload a file without the user's input. However, in the interests of showing the user...

validating mutiple drop downs list with the same name field in CakePHP 2.x

cakephp,drop-down-menu

find solution for my problem to avoid duplication of data,This link helps -> Validating multiple fields with the same name. All i have to do is put this code ->array('validate' => 'true')<- in this line if ($this->Group->save($this->request->data),array('validate' => 'true')) { and all done no need to disable the selected list...

CakePHP Unable to insert to database (datetime format)

database,datetime,cakephp,insert

Your problem is in view :) Change report to Report. Now when you are saving $this->request->data its trying to find Report key to be able to save , or report field in your database. If you dont want change this , in controller you can save $this->request->data['report'] Edit Also if...

cakephp 3 and view cells with use of Cookie

cakephp,cakephp-3.0

That of course won't work, view cells do not support the use of components, altough they can be thought of like "mini-controllers", they are not actually controllers in the terms of CakePHPs MVC system. Depending on whether the cookies are encrypted, you can either use the request object to fetch...

Port a MVC PHP project into CakePHP

php,cakephp

You could probably use ur old app as 3th party library in cakephp 3.0. But the cleaner and most likely easier way would be the port of application. If you did your mvc job good it should be a lot of copy pasting. Cakephp is convention over configuration so the...