cakephp-model

cakephp $this->data loses a LOT of its data array after form submit

我怕爱的太早我们不能终老 提交于 2020-01-06 18:12:45
问题 I have a manage_photos page whose $this->data contains a great deal of information about its Unit. I have a form which makes the appropriate changes in the database. However, upon submission of the form, $this->data (as seen when using pr($this->data)) loses MOST of its array data once the page refreshes. Here is the form code in my view: echo $this->Form->create('Unit', array( 'action' => 'manage_photos', 'type' => 'file', 'inputDefaults' => array( 'label' => false, 'div' => false ) ) );

cakephp $this->data loses a LOT of its data array after form submit

一笑奈何 提交于 2020-01-06 18:12:18
问题 I have a manage_photos page whose $this->data contains a great deal of information about its Unit. I have a form which makes the appropriate changes in the database. However, upon submission of the form, $this->data (as seen when using pr($this->data)) loses MOST of its array data once the page refreshes. Here is the form code in my view: echo $this->Form->create('Unit', array( 'action' => 'manage_photos', 'type' => 'file', 'inputDefaults' => array( 'label' => false, 'div' => false ) ) );

Can a CakePHP model change its table without being re-instantiated?

大憨熊 提交于 2020-01-04 21:45:45
问题 I'm working with an unchangeable legacy database schema where each instance of an object has its own table in the database with associated records. I need to change a model's useTable every time the model is instantiated, but retain Cake's nice caching and what not. Say I have many pad objects, which each have several note objects (Note belongsTo Pad, Pad hasMany Note). Each pad has a record in the pads table, however every note has it's own table in a database (say entitled 'pad_{id}'). This

cakephp model association/join with same table [closed]

社会主义新天地 提交于 2020-01-04 05:30:51
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I have a table that contains parents and children. I want to be able to build the model so that it returns the parents and their children i.e it associates with itself. ID Name ParentID 1 Parent 0 2 Child1 1 3

cakephp HABTM same model

二次信任 提交于 2020-01-02 12:44:52
问题 I have a site develop in cakephp 2.0 I want to make a HABTM relation to the same model: A product can has more products. I thinked to do in this mode into my model: class Product extends AppModel { public $name = 'Product'; public $useTable = 'products'; public $belongsTo = 'User'; public $actsAs = array('Containable'); public $hasAndBelongsToMany = array( 'Ingredient' => array( 'className' => 'Product', 'joinTable' => 'ingredients_products', 'foreignKey' => 'product_id',

cakephp HABTM same model

萝らか妹 提交于 2020-01-02 12:41:23
问题 I have a site develop in cakephp 2.0 I want to make a HABTM relation to the same model: A product can has more products. I thinked to do in this mode into my model: class Product extends AppModel { public $name = 'Product'; public $useTable = 'products'; public $belongsTo = 'User'; public $actsAs = array('Containable'); public $hasAndBelongsToMany = array( 'Ingredient' => array( 'className' => 'Product', 'joinTable' => 'ingredients_products', 'foreignKey' => 'product_id',

CakePHP using multiple databases for models

南笙酒味 提交于 2019-12-30 07:04:48
问题 Is it possible for certain models to be in one database and other models in another (using the same connection)? I have a number of read-only tables that I want shared between multiple installations of my system. Other tables need to be per-installation. For the sake of example, let's say users is the shared table, and posts is per-installation. In one schema (let's call it "shared") we have the users table, and in another schema ("mycake") is posts . I've been able to get the User model

How to find field through foreign key in cakephp3.x.x?

雨燕双飞 提交于 2019-12-25 04:42:43
问题 how to try like this, i already write in ItemsTable.php like this public function initialize(array $config) { $this->belongsTo('Categories', [ 'className' => 'Item', 'foreignKey' => 'cid', 'propertyName' => 'name' ]); } How do I display category name instead of Cid ? 来源: https://stackoverflow.com/questions/27718675/how-to-find-field-through-foreign-key-in-cakephp3-x-x

Error PDO Exception SQLSTATE[42000] when using CakeDC Users plugin

纵然是瞬间 提交于 2019-12-25 03:43:20
问题 Iam using cakephp 2.2.1 and trying to use the cakedc users plugin, when I try to create a user I get the following error, can anyone give some tips or advice to resolve this error - I have loaded all tables using the migrations plugin. Thanks in advance :). 2013-04-07 06:31:33 Error: [PDOException] SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near

How to Retrieve fields from linked Models

会有一股神秘感。 提交于 2019-12-25 02:14:48
问题 I have the following three database tables: Products ######## id title artist_id Arists ###### id profile person_id People ###### id first_name last_name In my Product model how do I create a method to return the product title along with the artist's first_name ? I have set up the following model associations: Product belongs to Artist Artist belongs to Person 回答1: Containable is definitely the way to go for filtering related records. Make sure to add $actsAs = array('Containable') into your