Questions tagged [cakephp-model]

App models are the classes that sit as the business layer in a CakePHP application.

App models classes are responsible for managing almost everything that happens regarding data, its validity, interactions and evolution of the information workflow in a CakePHP project.

Usually model classes represent data and are used in CakePHP applications for data access, more specifically they represent a database table but they are not limited to this, but can be used to access anything that manipulates data such as files, external web services, iCal events, or rows in a CSV file.

Source: Manual Reference

Example: (CakePHP 2.x)

App::uses('AppModel', 'Model');
class Ingredient extends AppModel {
    public $name = 'Ingredient';
}
501 questions
0
votes
2 answers

CakePHP controller method not writing to the DB

I am calling one controller method from another controller's method. I can confirm that the method is being called because when I do a print_r on the passed data, I see everything I expect. My problem is that when I call…
Captain Kenpachi
  • 6,960
  • 7
  • 47
  • 68
0
votes
1 answer

how i can fetch user data in a manyToMany association

I have a problem with CakePHP. I tested many ways, but can't find a solution for it. I have these…
Hadi Mostafapour
  • 1,994
  • 2
  • 13
  • 21
0
votes
1 answer

CakePHP doesn't see multiple relations HABTM while SQL query works fine

Cake query: $this->Token->find("first", array( "conditions" => array( "Token.token" => $token), "contain" => array( "TokenGroup" => array( "TokenPermission" => array("fields" =>…
Ziemo
  • 941
  • 8
  • 27
0
votes
1 answer

Multiple image upload - Meio Upload

I am using the 'MeioUpload' plugin found here 'https://github.com/jrbasso/MeioUpload' and Cakephp 2.x. Currently using this for single image uploads, please can anyone give advice on how to handle multiple image uploads using this plugin. Currently…
Joshua
  • 371
  • 2
  • 6
  • 23
0
votes
1 answer

cakePHP2.3 Save All

I am using Cakephp2.3 I have following tables Table 1 : Users Here i have field group_id and other fields Table 2 : Groups Table 3 : Students in which i have field user_id Table 4 : Guardians in which i have filed user_id And…
Rashmi
  • 551
  • 2
  • 4
  • 17
0
votes
1 answer

Working with abstract models in cakephp 1.2

I'm working on a project based on cakephp 1.2.2. And I'm having the following situation. I have a few model classes with the following hierarchy Human_Abstract extends AppModel { var $table = 'livingBeing'; } Man extends from…
0
votes
1 answer

Validation defined in model - CakePHP

Using CakePHP 1.3 I developed engine for blog with posts and comments tables and recently I have noticed that in database I've got records with null values in content column despite of the fact that Comment model has defined proper validation: …
Lukas Chojnacki
  • 105
  • 2
  • 9
0
votes
1 answer

virtual fields in associated view

I'm having $virtualFields of users set in the model public $virtualFields = array( 'fullname' => 'CONCAT(user.firstname, " ", user.lastname)', [...] ); I want to access this field in a associated view, but I can load users data like…
endo.anaconda
  • 2,449
  • 4
  • 29
  • 55
0
votes
1 answer

Find Followers and Followings Count in Cakephp

In my User model I have fields follower_count and following_count. And for followers and following I have HABTM association in my User as defined below: public $hasAndBelongsToMany=array( 'Following'=>array( 'className'=>'User', …
Meet Brahmbhatt
  • 57
  • 1
  • 1
  • 8
0
votes
1 answer

CakePHP: How to automagically set associated model ID for inserts/updates?

Good evening! I'm a bit confused by the magic of CakePHP. Some of it is amazing, but there is a tricky bit confusing me. I have a User Model, and an associated UserBasicInfo model: class User extends AppModel { public $name = 'User'; …
Neil
  • 205
  • 2
  • 10
0
votes
1 answer

How to echo Users' Comments for individual Events

Hi all Iam using Cakephp 2.x, I need to output individual users' comments for each individual event. Each user has many events and many comments. I have Events, Comments and Users models and want to allow users to post and view comments on each…
Joshua
  • 371
  • 2
  • 6
  • 23
0
votes
1 answer

Where should I put utility methods shared within my models?

I'm using CakePHP and was previously just storing sitewide methods in AppController, but when I call them from within my model, it just doesn't seem right. Should they be put in my AppModel instead?
bob_cobb
  • 2,229
  • 11
  • 49
  • 109
0
votes
2 answers

How to make a Model available in a View Cakephp 2.x

Hi all I have a 'profiles' table and I need to make this available in my default.ctp view file as I am trying to load profile images. I currently use the $current_user to access the 'users' in the form $current_user['filename']. My user and profile…
Joshua
  • 371
  • 2
  • 6
  • 23
0
votes
1 answer

CakePHP edit multiple records at once

I have a HABTM relationship between two tables: items and locations, using the table items_locations to join them. items_locations also stores a bit more information. Here's the schema items_locations(id, location_id, item_id, quantity) I'm trying…
nickf
  • 537,072
  • 198
  • 649
  • 721
0
votes
3 answers

Difference between HABTM relationship and 2 $belongsTo relationship with a third model

I'm creating a project management system which projects are assigned to users What's the difference between creating a Model ProjectsUser and defining 2 $belongsTo relationship and defining HABTM relationships in both Project and User models? What…
Rodrigo Souza
  • 7,162
  • 12
  • 41
  • 72