cakephp-2.0

CakePHP-2.0 How can i get the username from $allposts=$this->paginate('Post'); where user_id is foreign key of posts table?

喜欢而已 提交于 2019-12-12 04:35:45
问题 I'm using CakeDC-Users plugin. <?php class Post extends AppModel { public $useTable='posts'; public $belongsTo = array('User'); public $hasMany=array('Comment'); } I had to use paginate: $allposts=$this->paginate('Post'); I can get the user_id in this way: foreach ($allposts as $post) { debug($post['Post']['user_id']); But i need the username not the user_id. How can i get username? 回答1: The containble feature of CakPHP hides all associated models by default: http://book.cakephp.org/2.0/en

cakephp phone number validation

有些话、适合烂在心里 提交于 2019-12-12 03:46:35
问题 i am new to cakephp 2.x so i dont know how to do this .. i want to login the user from his email address and phone number..what my intention is if the number in database is this "12345" and the user is trying to login through this number "+12345" he can be login into the system.. i have written a code but i dont know how can i use this or to adjust my code within the auth component as the auth component is autometically logging the user .. here is my controller public function beforeFilter()

CakePHP restful routes

∥☆過路亽.° 提交于 2019-12-12 03:43:31
问题 I cannnot find anything useful about this. I am trying to create RESTful routing. Here is what I want my routes to look like: `GET` routes to `RecipesController::api_index() //instead of RecipesController::index()` `POST` routes to `RecipesController::api_add() //instead of RecipesController::add()` `PUT` routes to `RecipesController::api_edit($id) //instead of RecipesController:edit($id)` `DELETE` routes to `RecipesController::api_delete($id) //instead of RecipesController:delete($id)` I do

Is it possible to create a plugin inside a plugin with CakePHP?

孤街醉人 提交于 2019-12-12 03:42:18
问题 I am attemping to create a Plugin inside a Plugin using the CakePHP Framework. My folder structure is like so app/Plugin/SbnAdmin/Plugin/SbnChart/..... I am using the following line to load the SbnAdmin plugin CakePlugin::loadAll(array('SbnAdmin' => array('bootstrap' => true))); And in the SbnAdmin bootstrap I have CakePlugin::loadAll(); I am able to view a controller/model/view from the SbnAdmin plugin, but I am unable to access the SbnChart plugin... I have tried www..../sbn_admin/sbn_chart

CakePHP Model Query Return Data Formating

做~自己de王妃 提交于 2019-12-12 03:22:15
问题 I'm looking for a way to make it so cake returns all database data in the same format/structure... Currently it returns two different types of format depending on the relationship. If a model 'B' is associated with the current model 'A' being queried it will then place model associations for 'B' underneath it as you can see in [User] below. I want it so that all queries use that structure. example: $this->find('all', .... returns: Array ( [0] => Array ( [UserGroup] => Array ( [id] => 53 [user

Cakephp Plugin model name prefix

南笙酒味 提交于 2019-12-12 03:17:57
问题 I have a plugin with the name 'Admin' and my methods are like index, add etc. Since I want to apply unique model names and controller names (for ACL implementation), I prefixed all controllers and models with the plugin name (please see cakephp plugin model/controller cache issue with main model/controller). After that, Im facing the following problems. I have a table called users and I am using cakephp2.0. 1) I have to access the url with domain.com/admin/admin_users/index or admin/content

how to set containable behavior + cakephp2.x

偶尔善良 提交于 2019-12-12 03:05:10
问题 here is my containable condition $userStatusCondition = array('AND' => array( 'OR'=> array( 'TransactionStatus.buyer_status_id'=>$user_status_id, 'TransactionStatus.seller_status_id'=>$user_status_id, ) ) ); Merge conditions (other conditions + user_status condition) $transactions = $this->Transaction->find('all',array( 'conditions'=> Set::merge($otherConditions, $userStatusCondition), 'recursive'=>2)); in TransactionModel I set the public $actsAs = array('Containable'); public $belongsTo =

How to get data from two different table in cake php

二次信任 提交于 2019-12-12 03:04:20
问题 But it will give return same data from tab[1] only.. i want to get data from tab[1] and tab[0] distinctly $db = ConnectionManager::getDataSource('default'); $tab = $db->listSources(); echo '<br>'; $this->Form->useTable=$tab[1]; print_r($this->Form->find(`all')); echo '<br>'; $this->Form->use Table=$tab[0]; print_r($this->Form->find('all')); 回答1: Changing Model->useTable at runtime does not work properly because once a model has been initialised, CakePHP caches the schema of the database-table

Trying to save a hasMany array from multiple select

吃可爱长大的小学妹 提交于 2019-12-12 01:57:38
问题 I'm trying to save a data from a multiple select. This data is relacioned where "Request" hasMany "Requestc". The foriegnKey is "request_id" My Controller: if ($this->request->is('post')) { $solicitacao = $this->Request->save($this->request->data['Request']); //Verifica se a request foi salva e se sim, salva quais as certidões foram pedidas na tabela requests_certidoes if(!empty($solicitacao)) { $this->request->data['Requestc']['request_id'] = $this->Request->id; // debug($this->request->data

Can't get ajax to work in CakePHP

荒凉一梦 提交于 2019-12-12 01:52:53
问题 I am trying to run an ajax request in CakePHP 2.3. I am working off of this post: simple ajax example with cakephp 2.3.0 I cant get it to work, here is my code: $("#node-form-save").click(function(){ event.preventDefault(); var firstName = $("#node-form-first-name").val(); var lastName = $("#node-form-last-name").val(); var dob = $("#node-form-dob").val(); $.ajax({ url:'/persons/create', type: 'GET', datatype: 'json', data: {firstName: firstName, lastname: lastName, dob:dob}, success: