The saveAll is not working can some one help me in finding what is the problem.I have included the controller's action, the array passed to saveAll and the model of it.
The controllers action containing the saveAll looks like the following-
public function add_customer_order() {
if ($this->request->is('post')) {
-
-
-
-
$this->CustomerOrderItem->create();
if ($this->CustomerOrderItem->saveAll($customer_order_item)) {
$this->Session->setFlash('The customer order Items has been saved successfully.', 'default/flash_success');
}
else {
$this->Session->setFlash('The customer order Items not been saved successfully.', 'default/flash_success');
}
}
}
The array $customer_order_item looks as follows-
array(
'CustomerOrderItem' => array(
(int) 0 => array(
'id' => '',
'quantity' => '400',
'unit_cost' => '77',
'pending_quantity' => '400',
'packaging_configuration_quantity' => '20',
'exercise_duty_id' => '0',
'tax_id' => '5',
'customer_order_id' => '',
'master_article_id' => '22'
),
(int) 1 => array(
'id' => '',
'quantity' => '200',
'unit_cost' => '77',
'pending_quantity' => '200',
'packaging_configuration_quantity' => '20',
'exercise_duty_id' => '0',
'tax_id' => '5',
'customer_order_id' => '',
'master_article_id' => '25'
),
(int) 2 => array(
'id' => '',
'quantity' => '400',
'unit_cost' => '77',
'pending_quantity' => '400',
'packaging_configuration_quantity' => '20',
'exercise_duty_id' => '1',
'tax_id' => '5',
'customer_order_id' => '',
'master_article_id' => '23'
),
(int) 3 => array(
'id' => '',
'quantity' => '200',
'unit_cost' => '77',
'pending_quantity' => '200',
'packaging_configuration_quantity' => '20',
'exercise_duty_id' => '1',
'tax_id' => '5',
'customer_order_id' => '',
'master_article_id' => '24'
),
(int) 4 => array(
'id' => '',
'quantity' => '200',
'unit_cost' => '77',
'pending_quantity' => '200',
'packaging_configuration_quantity' => '20',
'exercise_duty_id' => '1',
'tax_id' => '5',
'customer_order_id' => '',
'master_article_id' => '27'
)
)
)
The model looks as follows-
<?php
App::uses('AppModel', 'Model');
/**
* CustomerOrderItem Model
*
* #property CustomerOrder $CustomerOrder
* #property MasterArticle $MasterArticle
*/
class CustomerOrderItem extends AppModel {
/**
* Validation rules
*
* #var array
*/
public $validate = array(
'customer_order_id' => array(
'numeric' => array(
'rule' => array('numeric'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'master_article_id' => array(
'numeric' => array(
'rule' => array('numeric'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
);
//The Associations below have been created with all possible keys, those that are not needed can be removed
/**
* belongsTo associations
*
* #var array
*/
public $belongsTo = array(
'CustomerOrder' => array(
'className' => 'CustomerOrder',
'foreignKey' => 'customer_order_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'MasterArticle' => array(
'className' => 'MasterArticle',
'foreignKey' => 'master_article_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
}
I am pretty sure it is a data issue either due to validation or null in db.
debug the contents of debug($this->request->data);
debug the invalid fields if any debug($this->Submission->invalidFields());. Make sure you call this after you have issues validates() request or saveAll()
Try
if ($this->CustomerOrderItem->saveAll($this->request->data)) {
First of all remove all the validation rules and then check again if error is still coming.if not then there must be issue with data validation rules or null value of 'customer_order_id'.
Related
I have a little problem. My Commodity model has Has and belongs to many association with User model. In the DB they are related through commodities_users table. So, I want Cakephp to create new records in commodities_users table in DB when the new Commodity was created. But it doesn't work.
My $this->request->data array (when I want saving one new commodity) looks like this
array(
'Commodity' => array(
'commodity_type' => '0',
'commoditygroup_id' => '',
'name' => 'asdfad',
'code' => '',
'ean' => '',
'costprice' => '',
'saleprice' => '12512,123',
'default_vatrate' => '',
'saleprice_gross' => '',
'sync_cashconnector' => '1',
'commoditysetting_id' => '',
'default_amount_enabled' => '0',
'default_amount' => '',
'stock_min' => '',
'stock' => '',
'comment' => ''
),
'User' => array(
(int) 0 => array(
'id' => '23'
),
(int) 1 => array(
'id' => '24'
),
(int) 2 => array(
'id' => '30'
),
(int) 3 => array(
'id' => '31'
)
));
And I am saving the Commodity model this way $this->Commodity->saveAll($this->request->data);
My cakePhp version is 2.4.
The relationship is
var $hasAndBelongsToMany = array(
'User' => array(
'className' => 'User',
'joinTable' => 'commodities_users',
'foreignKey' => 'commodity_id',
'associationForeignKey' => 'user_id',
),
);
What am I doing wrong ?
You are not feeding the right data into saveAll().
As per the CakePHP docs, the proper way of structuring your data is as follows:
array(
array(
'Commodity' => array(
'commodity_type' => '0',
'commoditygroup_id' => '',
'name' => 'asdfad',
'code' => '',
'ean' => '',
'costprice' => '',
'saleprice' => '12512,123',
'default_vatrate' => '',
'saleprice_gross' => '',
'sync_cashconnector' => '1',
'commoditysetting_id' => '',
'default_amount_enabled' => '0',
'default_amount' => '',
'stock_min' => '',
'stock' => '',
'comment' => ''
),
'User' => array(
'User' => array('23','24','30','31')
)
)
);
You then save the data with:
$this->Commodity->saveAll($this->request->data, array('deep' => true))
For further reference, see
Saving Related Model Data (HABTM)
Ok, I solved it by myself. I was just so dumm and wrote the HABTM association just in Commodity Model. Adding the same for User Model fixed the problem. And the $this->reuqest->data array looked so
array(
'Commodity' => array(
'commodity_type' => '0',
'commoditygroup_id' => '',
'name' => 'asdfad',
'code' => '',
'ean' => '',
'costprice' => '',
'saleprice' => '12512,123',
'default_vatrate' => '',
'saleprice_gross' => '',
'sync_cashconnector' => '1',
'commoditysetting_id' => '',
'default_amount_enabled' => '0',
'default_amount' => '',
'stock_min' => '',
'stock' => '',
'comment' => ''
),
'User' => array(
'id' => array(
'0' => '23',
'1' => '24',
'2' => '25'
));
Thanks for your time!
I have this code in model User:
$hasOne = array(
'Member' => array(
'className' => 'Member',
'foreignKey' => 'user_id',
'dependent' => true
)
);
function rest_findUserById($id = NULL) {
$row = $this->find(
'first',
array(
'contain' => array(
'UserSession'=>array(
'fields'=>array('user_id', 'session_token')
) ,
'Member' => array(
'fields' => array("*")
)
),
'fields' => array('username', 'email'),
'conditions' => array('User.id' => $id)
));
if (!$row) {
return FALSE;
}
debug($row);exit;
}
and in model Member:
$virtualFields = array(
'full_name' => 'CONCAT(Member.first_name, " ",Member.last_name)'
);
$belongsTo = array(
'Country' => array(
'className' => 'Country',
'foreignKey' => 'country_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'User' => array(
'className' => 'User',
'foreignKey' => 'user_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
?>
When I call fuction rest_findUserById() I get this output:
/app/Model/User.php (line 378)
array(
'User' => array(
'username' => 'testuser',
'email' => 'test#gmail.com',
'id' => '71'
),
'Member' => array(
'id' => '11',
'user_id' => '71',
'first_name' => 'Whjc',
'last_name' => 'test_user_lname',
'email' => '',
'phone' => '778899554455',
'image_dir' => '11',
'image' => '92e20fd0260dcc5ea289611221723b6a.jpg',
'address_line_1' => 'Shhd',
'address_line_2' => 'sdf',
'city' => 'Los Angeles Area',
'state' => 'delhi',
'country_id' => '0',
'zip_code' => '56456',
'is_address_different' => false,
'date_of_birth' => '0000-00-00',
'referred_by' => 'asdf',
'created' => '2016-07-27 13:52:30',
'created_by' => '3',
'modified' => '2016-08-02 12:25:22',
'modified_by' => '3',
'status' => false
),
'UserSession' => array(
(int) 0 => array(
'user_id' => '71',
'session_token' => 'a685b3db5ab87a928716c7d8b3272572'
)
)
)
but when I call this code:
$this->Member->recursive = -1;
debug($this->Member->find('first'));
I get this output:
/app/Model/User.php (line 377)
array(
'Member' => array(
'id' => '4',
'user_id' => '64',
'first_name' => 'SDFS SDF',
'last_name' => 'test_user_lname',
'email' => '',
'phone' => '778899554455',
'image_dir' => '',
'image' => '',
'address_line_1' => 'sdf',
'address_line_2' => 'sdf',
'city' => 'Los Angeles Area',
'state' => 'delhi',
'country_id' => '0',
'zip_code' => '56456',
'is_address_different' => false,
'date_of_birth' => '1970-01-01',
'referred_by' => 'asdf',
'created' => '2016-07-22 15:25:30',
'created_by' => '0',
'modified' => '2016-07-22 15:25:30',
'modified_by' => '0',
'status' => false,
'full_name' => 'SDFS SDF test_user_lname'
)
)
as you can see the virtual field i.e.'full_name' is coming in the second output but not in first output.
How can I fix this?
From the manual
you cannot use virtualFields on associated models
the proposed solution is to copy the virtual field into your model, this way
/app/Model/User.php
$this->virtualFields['member_full_name'] = $this->Member->virtualFields['full_name'];
Of course this does not work for hasMany or HABTM relationships. Also note that in this way you'll find the virtual field in the User data array and not in the Member data array
I have an array of behaviour $actas.Problem is when I adding date() function on the array string,it's return an error:
Example:
public $actas = array(
'Uploader.Attachment'=>array(
'books' => array(
'maxWidth' => 1200,
'maxHeight' => 1200,
'extension' => array('pdf'),
'nameCallback' => '',
'append' => '',
'prepend' => '',
'tempDir' => TMP,
'uploadDir' => '/var/www/html/apps/webroot/files/uploads/books' . date('d-m-Y'),//this is where I want to add the function.
'transportDir' => ''
)
)
);
however it's not working. I also do like this:
public $actas = array(
'Uploader.Attachment'=>array(
'books' => array(
'maxWidth' => 1200,
'maxHeight' => 1200,
'extension' => array('pdf'),
'nameCallback' => '',
'append' => '',
'prepend' => '',
'tempDir' => TMP,
'uploadDir' => "/var/www/html/apps/webroot/files/uploads/books'".date('d-m-Y')."'",//this is where I want to add the function.
'transportDir' => ''
)
)
);
also not worked.
So my question is how to do that? If I have a lot of mistaken,please tell me so I can learn more about the matter.
Thanks in advance.
This is the full source code of Post.php model
<?php
App::uses('AppModel', 'Model');
/**
* Post Model
*
* #property Tier $Tier
* #property Category $Category
* #property Comment $Comment
*/
class Post extends AppModel {
//var $now = 'CURDATE()';
/**
* Validation rules
*
* #var array
*/
public $validate = array(
'title' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'content' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
);
//The Associations below have been created with all possible keys, those that are not needed can be removed
/**
* belongsTo associations
*
* #var array
*/
public $belongsTo = array(
'Tier' => array(
'className' => 'Tier',
'foreignKey' => 'tier_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Category' => array(
'className' => 'Category',
'foreignKey' => 'category_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
/**
* hasMany associations
*
* #var array
*/
public $hasMany = array(
'Comment' => array(
'className' => 'Comment',
'foreignKey' => 'post_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
public $actsAs = array(
//'Containable',
'Uploader.Attachment' => array(
// Do not copy all these settings, it's merely an example
'banner' => array(
'maxWidth' => 1200,
'maxHeight' => 1200,
'extension' => array('gif', 'jpg', 'png', 'jpeg'),
'nameCallback' => '',
'append' => '',
'prepend' => '',
'tempDir' => TMP,
'uploadDir' => "/var/www/html/apps/webroot/img/banners/",
'transportDir' => '',
'finalPath' => '/img/banners/',
'dbColumn' => '',
'metaColumns' => array(),
'defaultPath' => '',
'overwrite' => true,
'transforms' => array(),
'stopSave' => true,
'allowEmpty' => true,
'transformers' => array(),
'transport' => array(),
'transporters' => array(),
'curl' => array()
),
'feature' => array(
'maxWidth' => 1200,
'maxHeight' => 1200,
'extension' => array('gif', 'jpg', 'png', 'jpeg'),
'nameCallback' => '',
'append' => '',
'prepend' => '',
'tempDir' => TMP,
'uploadDir' => '/var/www/html/apps/webroot/img/features/',
'transportDir' => '',
'finalPath' => '/img/features/',
'dbColumn' => '',
'metaColumns' => array(),
'defaultPath' => '',
'overwrite' => true,
'transforms' => array(),
'stopSave' => true,
'allowEmpty' => true,
'transformers' => array(),
'transport' => array(),
'transporters' => array(),
'curl' => array()
),
'books' => array(
'maxWidth' => 1200,
'maxHeight' => 1200,
'extension' => array('pdf'),
'nameCallback' => '',
'append' => '',
'prepend' => '',
'tempDir' => TMP,
'uploadDir' => '/var/www/html/apps/webroot/files/uploads/books' . date('d-m-Y'),
'transportDir' => '',
'finalPath' => '/files/uploads/books/',
'dbColumn' => '',
'metaColumns' => array(),
'defaultPath' => '',
'overwrite' => true,
'transforms' => array(),
'stopSave' => true,
'allowEmpty' => true,
'transformers' => array(),
'transport' => array(),
'transporters' => array(),
'curl' => array()
)
)
);
}
ahh ok I was not looking at it with my OO hat on. you can't do this because:
Properties
Class member variables are called "properties". You may also see them
referred to using other terms such as "attributes" or "fields", but
for the purposes of this reference we will use "properties". They are
defined by using one of the keywords public, protected, or private,
followed by a normal variable declaration. This declaration may
include an initialization, but this initialization must be a
constant value--that is, it must be able to be evaluated at compile
time and must not depend on run-time information in order to be
evaluated.
you need to use the __construct() method
I have Story related to a Chapter with a many to many relation
I have a StoryChapter Model .
I have this find all stories result :
array(
(int) 0 => array(
'Story' => array(
'id' => '111',
'title' => 'First Story',
'question' => 'What do you want ?',
'description' => 'ezrsrfgq ergtqergq',
'date' => '2014-06-10',
'image' => '/uploads/stories/111.jpg',
'created' => '2014-06-10 07:51:35',
'modified' => '2014-06-13 12:45:43',
'created_by' => '1',
'original' => null,
'tags' => ''
),
'StoryChapter' => array(
(int) 0 => array(
'id' => '110',
'story_id' => '111',
'chapter_id' => '81',
'chapter_title' => 'Second Chapter',
'created' => '2014-06-11 00:00:00'
),
(int) 1 => array(
'id' => '109',
'story_id' => '111',
'chapter_id' => '80',
'chapter_title' => 'First Chapter',
'created' => '2014-06-13 00:00:00'
)
),
'StoryUser' => array(),
'StoryGroup' => array(),
'Favorite' => array(),
'Tag' => array()
),
(int) 1 => array(
'Story' => array(
'id' => '112',
'title' => 'Second Story',
'question' => 'What do you want ?',
'description' => 'edghs rthsghsx ghs rhsgrhsrtgh',
'date' => '2014-06-13',
'image' => '/uploads/stories/112.jpg',
'created' => '2014-06-13 07:43:18',
'modified' => '2014-06-13 07:43:18',
'created_by' => '1',
'original' => null,
'tags' => ''
),
'StoryChapter' => array(),
'StoryUser' => array(),
'StoryGroup' => array(),
'Favorite' => array(),
'Tag' => array()
)
)
I want the find function to order only the StoryChapter by created desc without affecting the order of the found stories .
I hope you understand what I mean .
Thank you
I solved the problem by adding the order in the hasMany array in the Story model
public $hasMany = array(
'StoryChapter' => array(
'className' => 'StoryChapter',
'foreignKey' => 'story_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => 'created ASC',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
I am trying to export to a CSV in CakePHP.
Basically the problem that I am having is, the database is split down into multiple tables.
One for a product, one for artists and one for users.
It is all working well apart from the fact that the Email addresses for the artists are stored in the users table, I would like these to be included in the export. I have tried adding in the appropriate header for the column (csv) and then adding the
$result['Users']['username'],
Row that can be seen in my full function below, however it leaves the Email fields blank. Please help!
function export($event_id)
{
$this->layout = 'blank_layout';
ini_set('max_execution_time', 600); //increase max_execution_time to 10 min if data set is very large
//create a file
$filename = "export_".date("Y.m.d").".csv";
$csv_file = fopen('php://output', 'w');
header('Content-type: application/csv');
header('Content-Disposition: attachment; filename="'.$filename.'"');
$results = $this->Sculpture->find('all', array('conditions' => array('event_id' => $event_id), 'order' => 'artist_id'));
// The column headings of your .csv file
$header_row = array(
"Artist",
"Email",
"Sculpture",
"Materials",
"Description",
"Price",
"Notes"
);
fputcsv($csv_file,$header_row,',','"');
// Each iteration of this while loop will be a row in your .csv file where each field corresponds to the heading of the column
foreach($results as $result)
{
// Array indexes correspond to the field names in your db table(s)
$row = array(
$result['Artist']['name'],
$result['Users']['username'],
$result['Sculpture']['title'],
$result['Sculpture']['materials'],
$result['Sculpture']['description'],
$result['Sculpture']['price'],
$result['Sculpture']['notes'],
);
fputcsv($csv_file,$row,',','"');
}
fclose($csv_file);
}
Sculpture Model
<?php
App::uses('AppModel', 'Model');
/**
* Sculpture Model
*
* #property Artist $Artist
* #property Event $Event
*/
class Sculpture extends AppModel {
/**
* Validation rules
*
* #var array
*/
public $validate = array(
'artist_id' => array(
'numeric' => array(
'rule' => array('numeric'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'event_id' => array(
'numeric' => array(
'rule' => array('numeric'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'title' => array(
'notempty' => array(
'rule' => array('notempty'),
'message' => 'Please tell us the name of your sculpture',
'allowEmpty' => true,
'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'materials' => array(
'notempty' => array(
'rule' => array('notempty'),
'message' => 'Please tell us the materials used in this sculpture',
'allowEmpty' => true,
'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'price' => array(
'money' => array(
'rule' => array('numeric'),
'message' => 'Please include the price of your sculpture.'
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
)
);
public function beforeValidate()
{
//$p = $this->data['Sculpture']['price'];
// Get decimal place if available
//$dec = substr(, $start)
$this->data['Sculpture']['price'] = preg_replace("/[^0-9.]/", '', $this->data['Sculpture']['price']);
return true;
}
//The Associations below have been created with all possible keys, those that are not needed can be removed
/**
* belongsTo associations
*
* #var array
*/
public $belongsTo = array(
'Artist' => array(
'className' => 'Artist',
'foreignKey' => 'artist_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Event' => array(
'className' => 'Event',
'foreignKey' => 'event_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
/**
* hasAndBelongsToMany associations
*
* #var array
*/
public $hasAndBelongsToMany = array(
'MediaFile' => array(
'className' => 'MediaFile',
'joinTable' => 'sculptures_media_files',
'foreignKey' => 'sculpture_id',
'associationForeignKey' => 'media_file_id',
'unique' => 'keepExisting',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
)
);
}
NEW Error report
$this->loadModel('Artist');
$artist = $this->Artist->find('first', array('conditions' => array('Artist.user_id' => $this->Auth->user('id'))));
$this->set('artist_id', $artist['Artist']['id']);
EventsController::view() - APP/Controller/EventsController.php, line 78
ReflectionMethod::invokeArgs() - [internal], line ??
Controller::invokeAction() - CORE/Cake/Controller/Controller.php, line 486
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 187
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 162
[main] - APP/webroot/index.php, line 92
NEW NEW ERROR From Sculpture Model
$results = $this->Sculpture->find('all', array('conditions' => array('event_id' => $event_id), 'order' => 'artist_id', 'recursive' => 2));
debug($results); die();
The New error
$this->loadModel('Artist');
$artist = $this->Artist->find('first', array('conditions' => array('Artist.user_id' => $this->Auth->user('id'))));
$this->set('artist_id', $artist['Artist']['id']);
EventsController::view() - APP/Controller/EventsController.php, line 78
ReflectionMethod::invokeArgs() - [internal], line ??
Controller::invokeAction() - CORE/Cake/Controller/Controller.php, line 486
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 187
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 162
[main] - APP/webroot/index.php, line 92
<div class="cake-debug-output">
<span><strong>/app/Controller/SculpturesController.php</strong> (line <strong>70</strong>)</span>
<pre class="cake-debug">
array(
(int) 0 => array(
'Sculpture' => array(
'id' => '462',
'artist_id' => '1',
'event_id' => '1',
'title' => '',
'materials' => '',
'description' => '',
'edition' => '',
'price' => '0.00',
'vat' => false,
'media_file_id' => '0',
'delivery' => '2013-12-16',
'notes' => '',
'created' => '2013-12-16 12:52:14',
'modified' => '2013-12-16 12:52:14'
),
'Artist' => array(
'id' => '1',
'name' => 'Amanda Noble',
'website' => 'www.thefusedgarden.co.uk',
'materials' => 'Glass and stainless steel',
'location' => 'Northants',
'created' => '2013-04-30 14:53:25',
'modified' => '2013-07-09 15:21:53',
'user_id' => '11',
'User' => array(
'password' => '*****',
'id' => '11',
'username' => 'noblept#aol.co.uk',
'role_id' => '4',
'created' => '2013-07-01 15:26:40',
'modified' => '2013-07-01 15:26:40'
),
'Sculpture' => array(
(int) 0 => array(
'id' => '138',
'artist_id' => '1',
'event_id' => '2',
'title' => 'Midsummer Blue',
'materials' => 'Glass & Stainless Steel',
'description' => 'One of 3 fused glass panels. sold either as a single panel or as a set of 3',
'edition' => '',
'price' => '144.00',
'vat' => false,
'media_file_id' => '0',
'delivery' => '2013-07-28',
'notes' => 'When sold as a set of three the price is 10% lower.
We will arrive AM, but will not require assistance to install our sculptures',
'created' => '2013-07-09 15:06:56',
'modified' => '2013-07-09 15:21:07'
),
(int) 1 => array(
'id' => '159',
'artist_id' => '1',
'event_id' => '2',
'title' => 'Blue evening',
'materials' => 'Glass and Stainless Seel',
'description' => 'One of 3 fused glass panels sold either as a single panel or as a set of 3 ( the other 2 are Midsummer Blue and Blue Haze )',
'edition' => '',
'price' => '128.00',
'vat' => false,
'media_file_id' => '0',
'delivery' => '2013-07-29',
'notes' => 'Each panel is unique as no piece of fused glass will ever be identical, but it is possible to create a similar, but not exact replica of any panel.
The images shown are of a similar sets, but the actual exhibits are still in the process of creation and an image is not available.',
'created' => '2013-07-09 15:30:53',
'modified' => '2013-07-09 16:31:17'
),
if you are following cake namning convention it should be
$result['User']['username'],
(Model name must be singular and not plural)
edited after seeing Scuplure model file:
Because User is related to Artist Model (and not directly to Sculpture Model) you have to set 'recursive' parameter in your find call:
$results = $this->Sculpture->find(
'all',
array(
'conditions' => array('event_id' => $event_id),
'order' => 'artist_id',
'recursive' => 2
)
);