2005-08-21 06:49:02 +00:00
|
|
|
<?php
|
|
|
|
/* SVN FILE: $Id$ */
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
2005-09-07 01:52:45 +00:00
|
|
|
* Object-relational mapper.
|
2005-08-21 06:49:02 +00:00
|
|
|
*
|
2005-09-07 01:52:45 +00:00
|
|
|
* DBO-backed object data model, for mapping database tables to Cake objects.
|
2005-06-23 13:59:02 +00:00
|
|
|
*
|
2005-08-21 06:49:02 +00:00
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
|
|
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
|
|
|
* Copyright (c) 2005, CakePHP Authors/Developers
|
|
|
|
*
|
|
|
|
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
|
|
|
|
* Larry E. Masters aka PhpNut <nut@phpnut.com>
|
|
|
|
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
2005-06-23 13:59:02 +00:00
|
|
|
*
|
|
|
|
* @filesource
|
2005-08-21 06:49:02 +00:00
|
|
|
* @author CakePHP Authors/Developers
|
|
|
|
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
|
|
|
|
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
|
|
|
|
* @package cake
|
2005-10-09 01:56:21 +00:00
|
|
|
* @subpackage cake.cake.libs.model
|
2005-08-21 06:49:02 +00:00
|
|
|
* @since CakePHP v 0.2.9
|
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
2005-06-23 13:59:02 +00:00
|
|
|
* @lastmodified $Date$
|
2005-08-21 06:49:02 +00:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
2005-06-23 13:59:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*/
|
2005-08-21 06:49:02 +00:00
|
|
|
uses('object', 'class_registry', 'validators', 'inflector');
|
|
|
|
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
2005-08-21 06:49:02 +00:00
|
|
|
* Short description for class
|
|
|
|
*
|
2005-10-09 01:56:21 +00:00
|
|
|
* DBO-backed object data model.
|
2005-06-23 13:59:02 +00:00
|
|
|
* Automatically selects a database table name based on a pluralized lowercase object class name
|
|
|
|
* (i.e. class 'User' => table 'users'; class 'Man' => table 'men')
|
|
|
|
* The table is required to have at least 'id auto_increment', 'created datetime',
|
|
|
|
* and 'modified datetime' fields.
|
|
|
|
*
|
2005-08-21 06:49:02 +00:00
|
|
|
* @package cake
|
2005-10-09 01:56:21 +00:00
|
|
|
* @subpackage cake.cake.libs.model
|
2005-08-21 06:49:02 +00:00
|
|
|
* @since CakePHP v 0.2.9
|
2005-06-23 13:59:02 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
class Model extends Object
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var unknown_type
|
|
|
|
* @access public
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
var $parent = false;
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom database table name
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
[1242]
Author: phpnut
Date: 6:19:00 PM, Thursday, October 27, 2005
Message:
removing session directory
[1241]
Author: phpnut
Date: 6:13:46 PM, Thursday, October 27, 2005
Message:
added docblocks and temp error messages when trying to use the unimplemeted database for sessions
[1239]
Author: phpnut
Date: 5:28:57 PM, Thursday, October 27, 2005
Message:
More work on session.
Added config settings to core.php
updated model to allow models without a database table.
[1237]
Author: phpnut
Date: 3:50:27 PM, Thursday, October 27, 2005
Message:
adding directories for sessions
[1235]
Author: phpnut
Date: 3:36:08 AM, Thursday, October 27, 2005
Message:
Typo
[1234]
Author: phpnut
Date: 3:34:07 AM, Thursday, October 27, 2005
Message:
More work on the Session classes and adding the first methods the to Security class
[1233]
Author: phpnut
Date: 3:05:46 AM, Thursday, October 27, 2005
Message:
Start to core security class added.
Moved paths.php to cake/config/
Refactoring Session classes
[1232]
Author: phpnut
Date: 2:20:25 AM, Thursday, October 27, 2005
Message:
More work on the core session class.
Adding session component class.
Added fix for errors messages not working with validation.
Added possible fix for inflector now working on the word status.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1243 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-27 23:29:56 +00:00
|
|
|
var $useTable = null;
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var unknown_type
|
|
|
|
* @access public
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
var $id = false;
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Container for the data that this model gets from persistent storage (the database).
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access public
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
var $data = array();
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Table name for this Model.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
var $table = false;
|
2005-07-21 04:02:32 +00:00
|
|
|
|
2005-06-23 13:59:02 +00:00
|
|
|
/**
|
|
|
|
* Table metadata
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access private
|
|
|
|
*/
|
2005-09-18 13:25:20 +00:00
|
|
|
var $_tableInfo = null;
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
2005-08-21 06:49:02 +00:00
|
|
|
* Array of other Models this Model references in a belongsTo (one-to-one) relationship.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access private
|
|
|
|
*/
|
|
|
|
var $_belongsToOther = array();
|
2005-07-10 05:08:19 +00:00
|
|
|
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
|
2005-06-23 13:59:02 +00:00
|
|
|
/**
|
2005-08-21 06:49:02 +00:00
|
|
|
* Array of other Models this Model references in a hasOne (one-to-one) relationship.
|
2005-06-23 13:59:02 +00:00
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access private
|
|
|
|
*/
|
2005-08-21 06:49:02 +00:00
|
|
|
var $_oneToOne = array();
|
2005-06-23 13:59:02 +00:00
|
|
|
|
2005-08-21 06:49:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Array of other Models this Model references in a hasMany (one-to-many) relationship.
|
2005-06-23 13:59:02 +00:00
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access private
|
|
|
|
*/
|
2005-08-21 06:49:02 +00:00
|
|
|
var $_oneToMany = array();
|
2005-06-23 13:59:02 +00:00
|
|
|
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
|
2005-08-21 06:49:02 +00:00
|
|
|
/**
|
|
|
|
* Array of other Models this Model references in a hasAndBelongsToMany (many-to-many) relationship.
|
2005-06-23 13:59:02 +00:00
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access private
|
|
|
|
*/
|
2005-08-21 06:49:02 +00:00
|
|
|
var $_manyToMany = array();
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* append entries for validation as ('field_name' => '/^perl_compat_regexp$/') that has to match with preg_match()
|
|
|
|
* validate with Model::validate()
|
|
|
|
* @var array
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
var $validate = array();
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Append entries for validation as ('field_name' => '/^perl_compat_regexp$/') that has to match with preg_match()
|
|
|
|
* validate with Model::validate()
|
|
|
|
* @var array
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
var $validationErrors = null;
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
|
2005-07-10 05:08:19 +00:00
|
|
|
/**
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
* Prefix for tables in model.
|
2005-08-21 06:49:02 +00:00
|
|
|
*
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
* @var string
|
2005-08-21 06:49:02 +00:00
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
var $tablePrefix = null;
|
|
|
|
|
2005-08-21 06:49:02 +00:00
|
|
|
/**
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
* Name of the model.
|
2005-08-21 06:49:02 +00:00
|
|
|
*
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
* @var string
|
2005-08-21 06:49:02 +00:00
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
var $name = null;
|
|
|
|
|
2005-08-21 06:49:02 +00:00
|
|
|
/**
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
* Name of the model.
|
2005-08-21 06:49:02 +00:00
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
var $currentModel = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var unknown_type
|
|
|
|
*/
|
|
|
|
var $tableToModel = array();
|
2005-08-21 06:49:02 +00:00
|
|
|
|
2005-06-23 13:59:02 +00:00
|
|
|
/**
|
|
|
|
* Constructor. Binds the Model's database table to the object.
|
|
|
|
*
|
|
|
|
* @param unknown_type $id
|
|
|
|
* @param string $table Database table to use.
|
|
|
|
* @param unknown_type $db Database connection object.
|
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function __construct ($id=false, $table=null, $db=null)
|
|
|
|
{
|
[1178]
Author: phpnut
Date: 8:52:12 PM, Sunday, October 23, 2005
Message:
adding cakephp power image
[1177]
Author: phpnut
Date: 8:48:32 PM, Sunday, October 23, 2005
Message:
Updated scaffold to use new layout template.
[1176]
Author: phpnut
Date: 7:09:27 PM, Sunday, October 23, 2005
Message:
renaming cake/conf to cake/config
[1175]
Author: phpnut
Date: 7:06:04 PM, Sunday, October 23, 2005
Message:
moving tags.ini.php to cake/conf/tags.ini.php
[1174]
Author: phpnut
Date: 6:52:19 PM, Sunday, October 23, 2005
Message:
updating css/cake.scaffold.css
[1173]
Author: phpnut
Date: 6:46:07 PM, Sunday, October 23, 2005
Message:
updating css/cake.deafult.css and default layout
[1172]
Author: phpnut
Date: 6:42:48 PM, Sunday, October 23, 2005
Message:
updating css/cake.scaffold.css
[1171]
Author: phpnut
Date: 6:41:00 PM, Sunday, October 23, 2005
Message:
Adding spaces to tags.ini file
[1170]
Author: phpnut
Date: 6:37:17 PM, Sunday, October 23, 2005
Message:
Removing code that is no longer used
[1169]
Author: phpnut
Date: 6:34:24 PM, Sunday, October 23, 2005
Message:
removing files that are no longer used
[1168]
Author: phpnut
Date: 6:19:46 PM, Sunday, October 23, 2005
Message:
Cleaning up Scaffold class.
[1167]
Author: phpnut
Date: 5:26:27 PM, Sunday, October 23, 2005
Message:
Changes are added to remove the $this->models array that would hold the instance of the models.
Now they are available as $this->ModelName; This should be CamelCased.
Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted.
[1166]
Author: phpnut
Date: 3:53:08 PM, Sunday, October 23, 2005
Message:
Making change to allow setting the name of a class camel cased to fix issues with PHP 4.
In both the model and the controllers:
Model: var $name = 'ModelName';
Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController.
[1165]
Author: phpnut
Date: 1:45:17 PM, Sunday, October 23, 2005
Message:
Fix added for problems with key name that was added to the class registry when underscored
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
|
|
|
if($this->name === null)
|
|
|
|
{
|
|
|
|
$this->name = get_class($this);
|
|
|
|
}
|
|
|
|
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
$this->currentModel = Inflector::underscore($this->name);
|
|
|
|
|
|
|
|
if($db != null)
|
|
|
|
{
|
|
|
|
$this->db =& $db;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$dboFactory = DboFactory::getInstance();
|
|
|
|
$this->db =& $dboFactory ;
|
|
|
|
if(empty($this->db))
|
|
|
|
{
|
|
|
|
$this->_throwMissingConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$classRegistry =& ClassRegistry::getInstance();
|
[1178]
Author: phpnut
Date: 8:52:12 PM, Sunday, October 23, 2005
Message:
adding cakephp power image
[1177]
Author: phpnut
Date: 8:48:32 PM, Sunday, October 23, 2005
Message:
Updated scaffold to use new layout template.
[1176]
Author: phpnut
Date: 7:09:27 PM, Sunday, October 23, 2005
Message:
renaming cake/conf to cake/config
[1175]
Author: phpnut
Date: 7:06:04 PM, Sunday, October 23, 2005
Message:
moving tags.ini.php to cake/conf/tags.ini.php
[1174]
Author: phpnut
Date: 6:52:19 PM, Sunday, October 23, 2005
Message:
updating css/cake.scaffold.css
[1173]
Author: phpnut
Date: 6:46:07 PM, Sunday, October 23, 2005
Message:
updating css/cake.deafult.css and default layout
[1172]
Author: phpnut
Date: 6:42:48 PM, Sunday, October 23, 2005
Message:
updating css/cake.scaffold.css
[1171]
Author: phpnut
Date: 6:41:00 PM, Sunday, October 23, 2005
Message:
Adding spaces to tags.ini file
[1170]
Author: phpnut
Date: 6:37:17 PM, Sunday, October 23, 2005
Message:
Removing code that is no longer used
[1169]
Author: phpnut
Date: 6:34:24 PM, Sunday, October 23, 2005
Message:
removing files that are no longer used
[1168]
Author: phpnut
Date: 6:19:46 PM, Sunday, October 23, 2005
Message:
Cleaning up Scaffold class.
[1167]
Author: phpnut
Date: 5:26:27 PM, Sunday, October 23, 2005
Message:
Changes are added to remove the $this->models array that would hold the instance of the models.
Now they are available as $this->ModelName; This should be CamelCased.
Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted.
[1166]
Author: phpnut
Date: 3:53:08 PM, Sunday, October 23, 2005
Message:
Making change to allow setting the name of a class camel cased to fix issues with PHP 4.
In both the model and the controllers:
Model: var $name = 'ModelName';
Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController.
[1165]
Author: phpnut
Date: 1:45:17 PM, Sunday, October 23, 2005
Message:
Fix added for problems with key name that was added to the class registry when underscored
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
|
|
|
$classRegistry->addObject($this->currentModel, $this);
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
|
|
|
|
if ($id)
|
|
|
|
{
|
|
|
|
$this->id = $id;
|
|
|
|
}
|
[1242]
Author: phpnut
Date: 6:19:00 PM, Thursday, October 27, 2005
Message:
removing session directory
[1241]
Author: phpnut
Date: 6:13:46 PM, Thursday, October 27, 2005
Message:
added docblocks and temp error messages when trying to use the unimplemeted database for sessions
[1239]
Author: phpnut
Date: 5:28:57 PM, Thursday, October 27, 2005
Message:
More work on session.
Added config settings to core.php
updated model to allow models without a database table.
[1237]
Author: phpnut
Date: 3:50:27 PM, Thursday, October 27, 2005
Message:
adding directories for sessions
[1235]
Author: phpnut
Date: 3:36:08 AM, Thursday, October 27, 2005
Message:
Typo
[1234]
Author: phpnut
Date: 3:34:07 AM, Thursday, October 27, 2005
Message:
More work on the Session classes and adding the first methods the to Security class
[1233]
Author: phpnut
Date: 3:05:46 AM, Thursday, October 27, 2005
Message:
Start to core security class added.
Moved paths.php to cake/config/
Refactoring Session classes
[1232]
Author: phpnut
Date: 2:20:25 AM, Thursday, October 27, 2005
Message:
More work on the core session class.
Adding session component class.
Added fix for errors messages not working with validation.
Added possible fix for inflector now working on the word status.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1243 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-27 23:29:56 +00:00
|
|
|
if($this->useTable !== false)
|
|
|
|
{
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
$tableName = $table? $table: ($this->useTable? $this->useTable: Inflector::tableize($this->name));
|
|
|
|
|
|
|
|
if (in_array('settableprefix', get_class_methods($this->name)))
|
|
|
|
{
|
|
|
|
$this->setTablePrefix();
|
|
|
|
}
|
|
|
|
|
[1210]
Author: phpnut
Date: 4:44:45 AM, Wednesday, October 26, 2005
Message:
AJAX is now available as a by default in the $html variable in the templates.
You access it like this:
$html->Ajax->xxx();
Updated default templates.
[1208]
Author: phpnut
Date: 6:49:26 PM, Tuesday, October 25, 2005
Message:
Adding fix in Controller::generateFieldNames();
[1203]
Author: phpnut
Date: 10:40:28 AM, Tuesday, October 25, 2005
Message:
Changes made to core templates and css.
Fixed added for Ticket #60
[1202]
Author: phpnut
Date: 2:30:58 AM, Tuesday, October 25, 2005
Message:
Fix for cake error templates
Fixed a key for tables that are underscored in scaffolded code.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1211 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-26 10:55:44 +00:00
|
|
|
$this->tablePrefix? $this->setTable($this->tablePrefix.$tableName): $this->setTable($tableName);
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
|
|
|
|
parent::__construct();
|
|
|
|
$this->createLinks();
|
[1242]
Author: phpnut
Date: 6:19:00 PM, Thursday, October 27, 2005
Message:
removing session directory
[1241]
Author: phpnut
Date: 6:13:46 PM, Thursday, October 27, 2005
Message:
added docblocks and temp error messages when trying to use the unimplemeted database for sessions
[1239]
Author: phpnut
Date: 5:28:57 PM, Thursday, October 27, 2005
Message:
More work on session.
Added config settings to core.php
updated model to allow models without a database table.
[1237]
Author: phpnut
Date: 3:50:27 PM, Thursday, October 27, 2005
Message:
adding directories for sessions
[1235]
Author: phpnut
Date: 3:36:08 AM, Thursday, October 27, 2005
Message:
Typo
[1234]
Author: phpnut
Date: 3:34:07 AM, Thursday, October 27, 2005
Message:
More work on the Session classes and adding the first methods the to Security class
[1233]
Author: phpnut
Date: 3:05:46 AM, Thursday, October 27, 2005
Message:
Start to core security class added.
Moved paths.php to cake/config/
Refactoring Session classes
[1232]
Author: phpnut
Date: 2:20:25 AM, Thursday, October 27, 2005
Message:
More work on the core session class.
Adding session component class.
Added fix for errors messages not working with validation.
Added possible fix for inflector now working on the word status.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1243 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-27 23:29:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
2005-07-10 05:08:19 +00:00
|
|
|
/**
|
|
|
|
* Creates association relationships.
|
|
|
|
*
|
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function createLinks()
|
|
|
|
{
|
|
|
|
if (!empty($this->belongsTo))
|
2005-08-21 06:49:02 +00:00
|
|
|
{
|
|
|
|
$this->_belongsToLink();
|
|
|
|
}
|
|
|
|
if (!empty($this->hasOne))
|
|
|
|
{
|
|
|
|
$this->_hasOneLink();
|
|
|
|
}
|
|
|
|
if (!empty($this->hasMany))
|
|
|
|
{
|
|
|
|
$this->_hasManyLinks();
|
|
|
|
}
|
|
|
|
if (!empty($this->hasAndBelongsToMany))
|
|
|
|
{
|
|
|
|
$this->_hasAndBelongsToManyLinks();
|
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
2005-07-21 04:02:32 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @access private
|
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function _belongsToLink()
|
|
|
|
{
|
|
|
|
if(is_array($this->belongsTo))
|
|
|
|
{
|
|
|
|
foreach ($this->belongsTo as $association => $associationValue)
|
2005-07-21 04:02:32 +00:00
|
|
|
{
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
$className = $association;
|
|
|
|
$this->_associationSwitch($className, $associationValue, 'Belongs');
|
2005-07-21 04:02:32 +00:00
|
|
|
}
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$association = explode(',', $this->belongsTo);
|
|
|
|
foreach ($association as $className)
|
|
|
|
{
|
|
|
|
$this->_constructAssociatedModels($className , 'Belongs');
|
|
|
|
$this->linkAssociation('Belongs', $className, $this->id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-07-21 04:02:32 +00:00
|
|
|
|
2005-06-23 13:59:02 +00:00
|
|
|
/**
|
2005-07-10 05:08:19 +00:00
|
|
|
* Enter description here...
|
2005-06-23 13:59:02 +00:00
|
|
|
*
|
2005-07-10 05:08:19 +00:00
|
|
|
* @access private
|
2005-06-23 13:59:02 +00:00
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function _hasOneLink()
|
|
|
|
{
|
|
|
|
if(is_array($this->hasOne))
|
|
|
|
{
|
|
|
|
foreach ($this->hasOne as $association => $associationValue)
|
2005-07-10 05:08:19 +00:00
|
|
|
{
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
$className = $association;
|
|
|
|
$this->_associationSwitch($className, $associationValue, 'One');
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$association = explode(',', $this->hasOne);
|
|
|
|
foreach ($association as $className)
|
|
|
|
{
|
|
|
|
$this->_constructAssociatedModels($className , 'One');
|
|
|
|
$this->linkAssociation('One', $className, $this->id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
2005-07-21 04:02:32 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
* @access private
|
2005-07-21 04:02:32 +00:00
|
|
|
*/
|
2005-07-16 06:10:56 +00:00
|
|
|
function _hasManyLinks()
|
|
|
|
{
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
if(is_array($this->hasMany))
|
|
|
|
{
|
|
|
|
foreach ($this->hasMany as $association => $associationValue)
|
|
|
|
{
|
|
|
|
$className = $association;
|
|
|
|
$this->_associationSwitch($className, $associationValue, 'Many');
|
|
|
|
}
|
|
|
|
}
|
2005-07-16 06:10:56 +00:00
|
|
|
else
|
2005-08-21 06:49:02 +00:00
|
|
|
{
|
|
|
|
$association = explode(',', $this->hasMany);
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
foreach ($association as $className)
|
2005-08-21 06:49:02 +00:00
|
|
|
{
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
$this->_constructAssociatedModels($className , 'Many');
|
|
|
|
$this->linkAssociation('Many', $className, $this->id);
|
2005-08-21 06:49:02 +00:00
|
|
|
}
|
|
|
|
}
|
2005-07-16 06:10:56 +00:00
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
|
2005-08-21 06:49:02 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
* @access private
|
2005-08-21 06:49:02 +00:00
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function _hasAndBelongsToManyLinks()
|
|
|
|
{
|
|
|
|
if(is_array($this->hasAndBelongsToMany))
|
|
|
|
{
|
|
|
|
foreach ($this->hasAndBelongsToMany as $association => $associationValue)
|
|
|
|
{
|
|
|
|
$className = $association;
|
|
|
|
$this->_associationSwitch($className, $associationValue, 'ManyTo');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$association = explode(',', $this->hasAndBelongsToMany);
|
|
|
|
foreach ($association as $className)
|
|
|
|
{
|
|
|
|
$this->_constructAssociatedModels($className , 'ManyTo');
|
|
|
|
$this->linkAssociation('ManyTo', $className, $this->id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-23 13:59:02 +00:00
|
|
|
/**
|
2005-07-10 05:08:19 +00:00
|
|
|
* Enter description here...
|
2005-06-23 13:59:02 +00:00
|
|
|
*
|
2005-07-10 05:08:19 +00:00
|
|
|
* @param unknown_type $className
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
* @param unknown_type $associationValue
|
2005-07-10 05:08:19 +00:00
|
|
|
* @param unknown_type $type
|
|
|
|
* @access private
|
2005-06-23 13:59:02 +00:00
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function _associationSwitch($className, $associationValue, $type)
|
|
|
|
{
|
|
|
|
$classCreated = false;
|
|
|
|
|
|
|
|
foreach ($associationValue as $option => $optionValue)
|
|
|
|
{
|
|
|
|
if (($option === 'className') && ($classCreated === false))
|
|
|
|
{
|
|
|
|
$className = $optionValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($classCreated === false)
|
|
|
|
{
|
|
|
|
$this->_constructAssociatedModels($className , $type);
|
|
|
|
$classCreated = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch($option)
|
|
|
|
{
|
|
|
|
case 'associationForeignKey':
|
|
|
|
$this->{$className}->{$this->currentModel.'_associationforeignkey'} = $optionValue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'conditions':
|
|
|
|
$this->{$className}->{$this->currentModel.'_conditions'} = $optionValue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'counterCache':
|
|
|
|
$this->{$className}->{$this->currentModel.'_countercache'} = $optionValue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'counterSql':
|
|
|
|
$this->{$className}->{$this->currentModel.'_countersql'} = $optionValue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'deleteSql':
|
|
|
|
$this->{$className}->{$this->currentModel.'_deletesql'} = $optionValue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'dependent':
|
|
|
|
$this->{$className}->{$this->currentModel.'_dependent'} = $optionValue;
|
|
|
|
break;
|
2005-07-21 04:02:32 +00:00
|
|
|
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
case 'exclusive':
|
|
|
|
$this->{$className}->{$this->currentModel.'_exclusive'} = $optionValue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'finderSql':
|
|
|
|
$this->{$className}->{$this->currentModel.'_findersql'} = $optionValue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'foreignKey':
|
|
|
|
$this->{$className}->{$this->currentModel.'_foreignkey'} = $optionValue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'insertSql':
|
|
|
|
$this->{$className}->{$this->currentModel.'_insertsql'} = $optionValue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'joinTable':
|
|
|
|
$this->{$className}->{$this->currentModel.'_jointable'} = $optionValue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'order':
|
|
|
|
$this->{$className}->{$this->currentModel.'_order'} = $optionValue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'uniq':
|
|
|
|
$this->{$className}->{$this->currentModel.'_uniq'} = $optionValue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'fields':
|
|
|
|
$this->{$className}->{$this->currentModel.'_fields'} = $optionValue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->linkAssociation($type, $className, $this->id);
|
|
|
|
}
|
2005-07-21 04:02:32 +00:00
|
|
|
|
2005-07-10 05:08:19 +00:00
|
|
|
/**
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
* Enter description here...
|
2005-07-10 05:08:19 +00:00
|
|
|
*
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
* @param unknown_type $className
|
2005-07-21 04:02:32 +00:00
|
|
|
* @param unknown_type $type
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
* @access private
|
2005-07-10 05:08:19 +00:00
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function _constructAssociatedModels($className, $type)
|
|
|
|
{
|
|
|
|
$collectionKey = Inflector::underscore($className);
|
|
|
|
$classRegistry =& ClassRegistry::getInstance();
|
|
|
|
|
|
|
|
if(!$classRegistry->isKeySet($collectionKey))
|
|
|
|
{
|
|
|
|
$this->{$className} = new $className();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->{$className} = $classRegistry->getObject($collectionKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch($type)
|
|
|
|
{
|
|
|
|
case 'Belongs':
|
|
|
|
$this->{$className}->{$this->currentModel.'_conditions'} = null;
|
|
|
|
$this->{$className}->{$this->currentModel.'_order'} = null;
|
|
|
|
$this->{$className}->{$this->currentModel.'_foreignkey'} = Inflector::singularize($this->{$className}->table).'_id';
|
|
|
|
$this->{$className}->{$this->currentModel.'_countercache'} = null;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'One':
|
|
|
|
$this->{$className}->{$this->currentModel.'_conditions'} = null;
|
|
|
|
$this->{$className}->{$this->currentModel.'_order'} = null;
|
|
|
|
$this->{$className}->{$this->currentModel.'_dependent'} = null;
|
|
|
|
$this->{$className}->{$this->currentModel.'_foreignkey'} = Inflector::singularize($this->table).'_id';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Many':
|
|
|
|
$this->{$className}->{$this->currentModel.'_conditions'} = null;
|
|
|
|
$this->{$className}->{$this->currentModel.'_order'} = null;
|
|
|
|
$this->{$className}->{$this->currentModel.'_foreignkey'} = Inflector::singularize($this->table).'_id';
|
|
|
|
$this->{$className}->{$this->currentModel.'_fields'} = '*';
|
|
|
|
$this->{$className}->{$this->currentModel.'_dependent'} = null;
|
|
|
|
$this->{$className}->{$this->currentModel.'_exclusive'} = null;
|
|
|
|
$this->{$className}->{$this->currentModel.'_findersql'} = null;
|
|
|
|
$this->{$className}->{$this->currentModel.'_countersql'} = null;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'ManyTo':
|
|
|
|
$tableSort[0] = $this->table;
|
|
|
|
$tableSort[1] = $this->{$className}->table;
|
|
|
|
sort($tableSort);
|
|
|
|
$joinTable = $tableSort[0] . '_' . $tableSort[1];
|
|
|
|
$key1 = Inflector::singularize($this->table) . '_id';
|
|
|
|
$key2 = Inflector::singularize($this->{$className}->table) . '_id';
|
|
|
|
$this->{$className}->{$this->currentModel.'_jointable'} = $joinTable;
|
|
|
|
$this->{$className}->{$this->currentModel.'_fields'} = '*';
|
|
|
|
$this->{$className}->{$this->currentModel.'_foreignkey'} = $key1;
|
|
|
|
$this->{$className}->{$this->currentModel.'_associationforeignkey'} = $key2;
|
|
|
|
$this->{$className}->{$this->currentModel.'_conditions'} = null;
|
|
|
|
$this->{$className}->{$this->currentModel.'_order'} = null;
|
|
|
|
$this->{$className}->{$this->currentModel.'_uniq'} = null;
|
|
|
|
$this->{$className}->{$this->currentModel.'_findersql'} = null;
|
|
|
|
$this->{$className}->{$this->currentModel.'_deletesql'} = null;
|
|
|
|
$this->{$className}->{$this->currentModel.'_insertsql'} = null;
|
|
|
|
break;
|
|
|
|
}
|
[1198]
Author: phpnut
Date: 7:29:04 PM, Monday, October 24, 2005
Message:
More work on changes to use CamelCase throughout the system.
[1197]
Author: phpnut
Date: 2:57:08 PM, Monday, October 24, 2005
Message:
Removing unneeded calls to Inflector class
[1196]
Author: phpnut
Date: 2:39:30 PM, Monday, October 24, 2005
Message:
adding fix for Ticket #61
[1195]
Author: phpnut
Date: 11:19:43 AM, Monday, October 24, 2005
Message:
Adding fix for Ticket #47
[1194]
Author: phpnut
Date: 10:10:41 AM, Monday, October 24, 2005
Message:
Adding fix for Ticket #49
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1199 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-25 00:33:08 +00:00
|
|
|
$this->tableToModel[$this->{$className}->table] = $className;
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
}
|
2005-08-21 06:49:02 +00:00
|
|
|
|
2005-06-23 13:59:02 +00:00
|
|
|
/**
|
2005-07-21 04:02:32 +00:00
|
|
|
* Enter description here...
|
2005-06-23 13:59:02 +00:00
|
|
|
*
|
2005-07-21 04:02:32 +00:00
|
|
|
* @param unknown_type $type
|
|
|
|
* @param unknown_type $tableName
|
|
|
|
* @param unknown_type $value
|
2005-06-23 13:59:02 +00:00
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function linkAssociation ($type, $model, $value=null)
|
|
|
|
{
|
|
|
|
switch ($type)
|
|
|
|
{
|
|
|
|
case 'Belongs':
|
|
|
|
$this->_belongsToOther[] = array($model, $value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'One':
|
|
|
|
$this->_oneToOne[] = array($model, $value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Many':
|
|
|
|
$this->_oneToMany[] = array($model, $value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'ManyTo':
|
|
|
|
$this->_manyToMany[] = array($model, $value);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-07-21 04:02:32 +00:00
|
|
|
|
2005-06-23 13:59:02 +00:00
|
|
|
/**
|
|
|
|
* Sets a custom table for your controller class. Used by your controller to select a database table.
|
|
|
|
*
|
2005-09-18 13:25:20 +00:00
|
|
|
* @param string $tableName Name of the custom table
|
2005-06-23 13:59:02 +00:00
|
|
|
*/
|
[1210]
Author: phpnut
Date: 4:44:45 AM, Wednesday, October 26, 2005
Message:
AJAX is now available as a by default in the $html variable in the templates.
You access it like this:
$html->Ajax->xxx();
Updated default templates.
[1208]
Author: phpnut
Date: 6:49:26 PM, Tuesday, October 25, 2005
Message:
Adding fix in Controller::generateFieldNames();
[1203]
Author: phpnut
Date: 10:40:28 AM, Tuesday, October 25, 2005
Message:
Changes made to core templates and css.
Fixed added for Ticket #60
[1202]
Author: phpnut
Date: 2:30:58 AM, Tuesday, October 25, 2005
Message:
Fix for cake error templates
Fixed a key for tables that are underscored in scaffolded code.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1211 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-26 10:55:44 +00:00
|
|
|
function setTable($tableName)
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
{
|
|
|
|
if (!in_array(strtolower($tableName), $this->db->tables()))
|
|
|
|
{
|
|
|
|
$this->_throwMissingTable($tableName);
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->table = $tableName;
|
[1198]
Author: phpnut
Date: 7:29:04 PM, Monday, October 24, 2005
Message:
More work on changes to use CamelCase throughout the system.
[1197]
Author: phpnut
Date: 2:57:08 PM, Monday, October 24, 2005
Message:
Removing unneeded calls to Inflector class
[1196]
Author: phpnut
Date: 2:39:30 PM, Monday, October 24, 2005
Message:
adding fix for Ticket #61
[1195]
Author: phpnut
Date: 11:19:43 AM, Monday, October 24, 2005
Message:
Adding fix for Ticket #47
[1194]
Author: phpnut
Date: 10:10:41 AM, Monday, October 24, 2005
Message:
Adding fix for Ticket #49
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1199 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-25 00:33:08 +00:00
|
|
|
$this->tableToModel[$this->table] = $this->name;
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
$this->loadInfo();
|
|
|
|
}
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function does two things: 1) it scans the array $one for they key 'id',
|
|
|
|
* and if that's found, it sets the current id to the value of $one[id].
|
|
|
|
* For all other keys than 'id' the keys and values of $one are copied to the 'data' property of this object.
|
|
|
|
* 2) Returns an array with all of $one's keys and values.
|
|
|
|
* (Alternative indata: two strings, which are mangled to
|
|
|
|
* a one-item, two-dimensional array using $one for a key and $two as its value.)
|
|
|
|
*
|
|
|
|
* @param mixed $one Array or string of data
|
|
|
|
* @param string $two Value string for the alternative indata method
|
|
|
|
* @return unknown
|
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function set ($one, $two=null)
|
|
|
|
{
|
|
|
|
$this->validationErrors = null;
|
|
|
|
$data = is_array($one)? $one : array($one=>$two);
|
|
|
|
|
|
|
|
foreach ($data as $n => $v)
|
|
|
|
{
|
|
|
|
foreach ($v as $x => $y)
|
|
|
|
{
|
|
|
|
if($x == 'id')
|
|
|
|
{
|
|
|
|
$this->id = $y;
|
|
|
|
}
|
|
|
|
$this->data[$n][$x] = $y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets current Model id to given $id.
|
|
|
|
*
|
|
|
|
* @param int $id Id
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
*/
|
|
|
|
function setId ($id)
|
|
|
|
{
|
|
|
|
$this->id = $id;
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array of table metadata (column names and types) from the database.
|
|
|
|
*
|
|
|
|
* @return array Array of table metadata
|
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function loadInfo ()
|
|
|
|
{
|
|
|
|
if (empty($this->_tableInfo))
|
|
|
|
{
|
|
|
|
$this->_tableInfo = new NeatArray($this->db->fields($this->table));
|
|
|
|
}
|
|
|
|
return $this->_tableInfo;
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if given field name exists in this Model's database table.
|
|
|
|
* Starts by loading the metadata into the private property table_info if that is not already set.
|
|
|
|
*
|
|
|
|
* @param string $name Name of table to look in
|
|
|
|
* @return boolean
|
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function hasField ($name)
|
|
|
|
{
|
|
|
|
if (empty($this->_tableInfo))
|
|
|
|
{
|
|
|
|
$this->loadInfo();
|
|
|
|
}
|
|
|
|
return $this->_tableInfo->findIn('name', $name);
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a list of fields from the database
|
|
|
|
*
|
|
|
|
* @param mixed $fields String of single fieldname, or an array of fieldnames.
|
|
|
|
* @return array Array of database fields
|
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function read ($fields=null)
|
|
|
|
{
|
|
|
|
$this->validationErrors = null;
|
|
|
|
if(is_array($this->id))
|
|
|
|
{
|
|
|
|
return $this->id? $this->find("$this->table.id = '{$this->id[0]}'", $fields): false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return $this->id? $this->find("$this->table.id = '{$this->id}'", $fields): false;
|
|
|
|
}
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns contents of a field in a query matching given conditions.
|
|
|
|
*
|
|
|
|
* @param string $name Name of field to get
|
|
|
|
* @param string $conditions SQL conditions (defaults to NULL)
|
|
|
|
* @return field contents
|
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function field ($name, $conditions=null, $order=null)
|
|
|
|
{
|
[1210]
Author: phpnut
Date: 4:44:45 AM, Wednesday, October 26, 2005
Message:
AJAX is now available as a by default in the $html variable in the templates.
You access it like this:
$html->Ajax->xxx();
Updated default templates.
[1208]
Author: phpnut
Date: 6:49:26 PM, Tuesday, October 25, 2005
Message:
Adding fix in Controller::generateFieldNames();
[1203]
Author: phpnut
Date: 10:40:28 AM, Tuesday, October 25, 2005
Message:
Changes made to core templates and css.
Fixed added for Ticket #60
[1202]
Author: phpnut
Date: 2:30:58 AM, Tuesday, October 25, 2005
Message:
Fix for cake error templates
Fixed a key for tables that are underscored in scaffolded code.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1211 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-26 10:55:44 +00:00
|
|
|
if (isset($this->data[$this->name][$name]))
|
|
|
|
{
|
|
|
|
return $this->data[$this->name][$name];
|
|
|
|
}
|
|
|
|
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
if ($conditions)
|
|
|
|
{
|
|
|
|
$conditions = $this->parseConditions($conditions);
|
|
|
|
}
|
[1210]
Author: phpnut
Date: 4:44:45 AM, Wednesday, October 26, 2005
Message:
AJAX is now available as a by default in the $html variable in the templates.
You access it like this:
$html->Ajax->xxx();
Updated default templates.
[1208]
Author: phpnut
Date: 6:49:26 PM, Tuesday, October 25, 2005
Message:
Adding fix in Controller::generateFieldNames();
[1203]
Author: phpnut
Date: 10:40:28 AM, Tuesday, October 25, 2005
Message:
Changes made to core templates and css.
Fixed added for Ticket #60
[1202]
Author: phpnut
Date: 2:30:58 AM, Tuesday, October 25, 2005
Message:
Fix for cake error templates
Fixed a key for tables that are underscored in scaffolded code.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1211 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-26 10:55:44 +00:00
|
|
|
|
|
|
|
if ($data = $this->find($conditions, $name, $order))
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
{
|
[1210]
Author: phpnut
Date: 4:44:45 AM, Wednesday, October 26, 2005
Message:
AJAX is now available as a by default in the $html variable in the templates.
You access it like this:
$html->Ajax->xxx();
Updated default templates.
[1208]
Author: phpnut
Date: 6:49:26 PM, Tuesday, October 25, 2005
Message:
Adding fix in Controller::generateFieldNames();
[1203]
Author: phpnut
Date: 10:40:28 AM, Tuesday, October 25, 2005
Message:
Changes made to core templates and css.
Fixed added for Ticket #60
[1202]
Author: phpnut
Date: 2:30:58 AM, Tuesday, October 25, 2005
Message:
Fix for cake error templates
Fixed a key for tables that are underscored in scaffolded code.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1211 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-26 10:55:44 +00:00
|
|
|
return isset($data[$this->name][$name])? $data[$this->name][$name]: false;
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
[1210]
Author: phpnut
Date: 4:44:45 AM, Wednesday, October 26, 2005
Message:
AJAX is now available as a by default in the $html variable in the templates.
You access it like this:
$html->Ajax->xxx();
Updated default templates.
[1208]
Author: phpnut
Date: 6:49:26 PM, Tuesday, October 25, 2005
Message:
Adding fix in Controller::generateFieldNames();
[1203]
Author: phpnut
Date: 10:40:28 AM, Tuesday, October 25, 2005
Message:
Changes made to core templates and css.
Fixed added for Ticket #60
[1202]
Author: phpnut
Date: 2:30:58 AM, Tuesday, October 25, 2005
Message:
Fix for cake error templates
Fixed a key for tables that are underscored in scaffolded code.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1211 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-26 10:55:44 +00:00
|
|
|
return false;
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
}
|
|
|
|
}
|
[1210]
Author: phpnut
Date: 4:44:45 AM, Wednesday, October 26, 2005
Message:
AJAX is now available as a by default in the $html variable in the templates.
You access it like this:
$html->Ajax->xxx();
Updated default templates.
[1208]
Author: phpnut
Date: 6:49:26 PM, Tuesday, October 25, 2005
Message:
Adding fix in Controller::generateFieldNames();
[1203]
Author: phpnut
Date: 10:40:28 AM, Tuesday, October 25, 2005
Message:
Changes made to core templates and css.
Fixed added for Ticket #60
[1202]
Author: phpnut
Date: 2:30:58 AM, Tuesday, October 25, 2005
Message:
Fix for cake error templates
Fixed a key for tables that are underscored in scaffolded code.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1211 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-26 10:55:44 +00:00
|
|
|
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Saves a single field to the database.
|
|
|
|
*
|
|
|
|
* @param string $name Name of the table field
|
|
|
|
* @param mixed $value Value of the field
|
|
|
|
* @return boolean True on success save
|
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function saveField($name, $value)
|
|
|
|
{
|
|
|
|
return Model::save(array($this->table=>array($name=>$value)), false);
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Saves model data to the database.
|
|
|
|
*
|
|
|
|
* @param array $data Data to save.
|
|
|
|
* @param boolean $validate
|
|
|
|
* @return boolean success
|
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function save ($data=null, $validate=true)
|
|
|
|
{
|
|
|
|
if ($data)
|
|
|
|
{
|
|
|
|
$this->set($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($validate && !$this->validates())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$fields = $values = array();
|
|
|
|
|
|
|
|
$count = 0;
|
|
|
|
if(count($this->data) > 1)
|
2005-08-22 02:48:37 +00:00
|
|
|
{
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
$weHaveMulti = true;
|
|
|
|
$joined = false;
|
2005-08-22 02:48:37 +00:00
|
|
|
}
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
else
|
2005-08-22 02:48:37 +00:00
|
|
|
{
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
$weHaveMulti = false;
|
2005-08-22 02:48:37 +00:00
|
|
|
}
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
|
|
|
|
foreach ($this->data as $n=>$v)
|
|
|
|
{
|
|
|
|
if(isset($weHaveMulti) && $count > 0 && !empty($this->_manyToMany))
|
2005-07-10 05:08:19 +00:00
|
|
|
{
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
$joined[] = $v;
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
else
|
2005-07-10 05:08:19 +00:00
|
|
|
{
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
foreach ($v as $x => $y)
|
|
|
|
{
|
|
|
|
if ($this->hasField($x))
|
|
|
|
{
|
|
|
|
$fields[] = $x;
|
|
|
|
$values[] = (ini_get('magic_quotes_gpc') == 1) ?
|
|
|
|
$this->db->prepare(stripslashes($y)) : $this->db->prepare($y);
|
|
|
|
|
|
|
|
if($x == 'id' && !is_numeric($y))
|
|
|
|
{
|
|
|
|
$newID = $y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$count++;
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($this->id) && $this->hasField('created') && !in_array('created', $fields))
|
|
|
|
{
|
|
|
|
$fields[] = 'created';
|
|
|
|
$values[] = date("'Y-m-d H:i:s'");
|
|
|
|
}
|
|
|
|
if ($this->hasField('modified') && !in_array('modified', $fields))
|
|
|
|
{
|
|
|
|
$fields[] = 'modified';
|
|
|
|
$values[] = 'NOW()';
|
|
|
|
}
|
|
|
|
if(!$this->exists())
|
|
|
|
{
|
|
|
|
$this->id = false;
|
|
|
|
}
|
|
|
|
if(count($fields))
|
|
|
|
{
|
|
|
|
if(!empty($this->id))
|
2005-07-10 05:08:19 +00:00
|
|
|
{
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
$sql = array();
|
|
|
|
foreach (array_combine($fields, $values) as $field=>$value)
|
|
|
|
{
|
|
|
|
$sql[] = $field.'='.$value;
|
|
|
|
}
|
|
|
|
|
|
|
|
$sql = "UPDATE {$this->table} SET ".join(',', $sql)." WHERE id = '{$this->id}'";
|
|
|
|
|
|
|
|
if ($this->db->query($sql))
|
|
|
|
{
|
|
|
|
if(!empty($joined))
|
|
|
|
{
|
|
|
|
$this->_saveMulti($joined, $this->id);
|
|
|
|
}
|
|
|
|
$this->data = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return $this->db->hasAny($this->table, "id = '{$this->id}'");
|
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
$fields = join(',', $fields);
|
|
|
|
$values = join(',', $values);
|
|
|
|
|
|
|
|
$sql = "INSERT INTO {$this->table} ({$fields}) VALUES ({$values})";
|
|
|
|
|
|
|
|
if($this->db->query($sql))
|
|
|
|
{
|
|
|
|
$this->id = $this->db->lastInsertId($this->table, 'id');
|
|
|
|
if(!empty($joined))
|
|
|
|
{
|
|
|
|
if(!$this->id > 0 && isset($newID))
|
|
|
|
{
|
|
|
|
$this->id = $newID;
|
|
|
|
}
|
|
|
|
$this->_saveMulti($joined, $this->id);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
2005-08-22 02:48:37 +00:00
|
|
|
/**
|
|
|
|
* Saves model hasAndBelongsToMany data to the database.
|
|
|
|
*
|
|
|
|
* @param array $joined Data to save.
|
|
|
|
* @param string $id
|
2005-08-25 16:40:50 +00:00
|
|
|
* @return
|
|
|
|
* @access private
|
2005-08-22 02:48:37 +00:00
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function _saveMulti ($joined, $id)
|
|
|
|
{
|
|
|
|
foreach ($joined as $x => $y)
|
|
|
|
{
|
|
|
|
foreach ($y as $name => $value)
|
|
|
|
{
|
2005-10-24 07:51:09 +00:00
|
|
|
$name = Inflector::camelize($name);
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
$joinTable[] = $this->{$name}->{$this->currentModel.'_jointable'};
|
|
|
|
$mainKey = $this->{$name}->{$this->currentModel.'_foreignkey'};
|
|
|
|
$keys[] = $mainKey;
|
|
|
|
$keys[] = $this->{$name}->{$this->currentModel.'_associationforeignkey'};
|
|
|
|
$fields[] = join(',', $keys);
|
|
|
|
unset($keys);
|
|
|
|
|
|
|
|
foreach ($value as $update)
|
|
|
|
{
|
|
|
|
if(!empty($update))
|
|
|
|
{
|
|
|
|
$values[] = (ini_get('magic_quotes_gpc') == 1) ? $this->db->prepare(stripslashes($id)) : $this->db->prepare($id);
|
|
|
|
$values[] = (ini_get('magic_quotes_gpc') == 1) ? $this->db->prepare(stripslashes($update)) : $this->db->prepare($update);
|
|
|
|
$values = join(',', $values);
|
|
|
|
$newValues[] = "({$values})";
|
|
|
|
unset($values);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!empty($newValues))
|
|
|
|
{
|
|
|
|
$newValue[] = join(',', $newValues);
|
|
|
|
unset($newValues);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for ($count = 0; $count < count($joinTable); $count++)
|
|
|
|
{
|
|
|
|
$this->db->query("DELETE FROM {$joinTable[$count]} WHERE $mainKey = '{$id}'");
|
|
|
|
if(!empty($newValue[$count]))
|
|
|
|
{
|
|
|
|
$this->db->query("INSERT INTO {$joinTable[$count]} ({$fields[$count]}) VALUES {$newValue[$count]}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-08-22 02:48:37 +00:00
|
|
|
|
2005-06-23 13:59:02 +00:00
|
|
|
/**
|
|
|
|
* Synonym for del().
|
|
|
|
*
|
|
|
|
* @param mixed $id
|
|
|
|
* @see function del
|
|
|
|
* @return boolean True on success
|
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function remove ($id=null)
|
|
|
|
{
|
|
|
|
return $this->del($id);
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes record for given id. If no id is given, the current id is used. Returns true on success.
|
|
|
|
*
|
|
|
|
* @param mixed $id Id of database record to delete
|
|
|
|
* @return boolean True on success
|
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function del ($id=null)
|
|
|
|
{
|
|
|
|
if ($id)
|
|
|
|
{
|
|
|
|
$this->id = $id;
|
|
|
|
}
|
|
|
|
if ($this->id && $this->db->query("DELETE FROM {$this->table} WHERE id = '{$this->id}'"))
|
|
|
|
{
|
|
|
|
$this->id = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if a record with set id exists.
|
|
|
|
*
|
|
|
|
* @return boolean True if such a record exists
|
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function exists ()
|
|
|
|
{
|
|
|
|
return $this->id? $this->db->hasAny($this->table, "id = '{$this->id}'"): false;
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if a record that meets given conditions exists
|
|
|
|
*
|
|
|
|
* @return boolean True if such a record exists
|
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function hasAny ($conditions = null)
|
|
|
|
{
|
|
|
|
return $this->findCount($conditions);
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a single row as a resultset array.
|
|
|
|
*
|
|
|
|
* @param string $conditions SQL conditions
|
|
|
|
* @param mixed $fields Either a single string of a field name, or an array of field names
|
|
|
|
* @param string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC")
|
|
|
|
* @return array Array of records
|
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function find ($conditions = null, $fields = null, $order = null)
|
|
|
|
{
|
|
|
|
$data = Model::findAll($conditions, $fields, $order, 1);
|
|
|
|
return empty($data[0])? false: $data[0];
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/** parses conditions array (or just passes it if it's a string)
|
|
|
|
* @return string
|
|
|
|
*
|
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function parseConditions ($conditions)
|
|
|
|
{
|
|
|
|
if (is_string($conditions))
|
|
|
|
{
|
|
|
|
return $conditions;
|
|
|
|
}
|
|
|
|
elseif (is_array($conditions))
|
|
|
|
{
|
|
|
|
$out = array();
|
|
|
|
foreach ($conditions as $key=>$value)
|
|
|
|
{
|
|
|
|
$slashedValue = (ini_get('magic_quotes_gpc') == 1) ? $this->db->prepare(stripslashes($value)) : $this->db->prepare($value);
|
|
|
|
//Should remove the = below so LIKE and other compares can be used
|
|
|
|
$out[] = "{$key}=".($value===null? 'null': $slashedValue);
|
|
|
|
}
|
|
|
|
return join(' and ', $out);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a resultset array with specified fields from database matching given conditions.
|
|
|
|
*
|
|
|
|
* @param mixed $conditions SQL conditions as a string or as an array('field'=>'value',...)
|
|
|
|
* @param mixed $fields Either a single string of a field name, or an array of field names
|
|
|
|
* @param string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC")
|
|
|
|
* @param int $limit SQL LIMIT clause, for calculating items per page
|
|
|
|
* @param int $page Page number
|
|
|
|
* @return array Array of records
|
|
|
|
*/
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
function findAll ($conditions = null, $fields = null, $order = null, $limit=50, $page=1)
|
|
|
|
{
|
|
|
|
$conditions = $this->parseConditions($conditions);
|
|
|
|
|
|
|
|
if (is_array($fields))
|
|
|
|
{
|
|
|
|
$f = $fields;
|
|
|
|
}
|
|
|
|
elseif ($fields)
|
|
|
|
{
|
|
|
|
$f = array($fields);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$f = array('*');
|
|
|
|
}
|
|
|
|
|
|
|
|
$joins = $whers = array();
|
2005-08-21 06:49:02 +00:00
|
|
|
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
if(!empty($this->_oneToOne))
|
|
|
|
{
|
|
|
|
foreach ($this->_oneToOne as $rule)
|
|
|
|
{
|
|
|
|
list($model, $value) = $rule;
|
|
|
|
if(!empty($this->{$model}->{$this->currentModel.'_foreignkey'}))
|
|
|
|
{
|
|
|
|
$oneToOneConditions = $this->parseConditions($this->{$model}->{$this->currentModel.'_conditions'});
|
|
|
|
$oneToOneOrder = $this->{$model}->{$this->currentModel.'_order'};
|
|
|
|
|
|
|
|
$joins[] = "LEFT JOIN {$this->{$model}->table} ON
|
|
|
|
{$this->{$model}->table}.{$this->{$model}->{$this->currentModel.'_foreignkey'}} = {$this->table}.id"
|
|
|
|
.($oneToOneConditions? " WHERE {$oneToOneConditions}":null)
|
|
|
|
.($oneToOneOrder? " ORDER BY {$oneToOneOrder}": null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!empty($this->_belongsToOther))
|
|
|
|
{
|
|
|
|
foreach ($this->_belongsToOther as $rule)
|
|
|
|
{
|
|
|
|
list($model, $value) = $rule;
|
|
|
|
if(!empty($this->{$model}->{$this->currentModel.'_foreignkey'}))
|
|
|
|
{
|
|
|
|
$belongsToOtherConditions = $this->parseConditions($this->{$model}->{$this->currentModel.'_conditions'});
|
|
|
|
$belongsToOtherOrder = $this->{$model}->{$this->currentModel.'_order'};
|
|
|
|
|
|
|
|
$joins[] = "LEFT JOIN {$this->{$model}->table} ON
|
|
|
|
{$this->table}.{$this->{$model}->{$this->currentModel.'_foreignkey'}} = {$this->{$model}->table}.id"
|
|
|
|
.($belongsToOtherConditions? " WHERE {$belongsToOtherConditions}":null)
|
|
|
|
.($belongsToOtherOrder? " ORDER BY {$belongsToOtherOrder}": null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$joins = count($joins)? join(' ', $joins): null;
|
|
|
|
$whers = count($whers)? '('.join(' AND ', $whers).')': null;
|
|
|
|
$conditions .= ($conditions && $whers? ' AND ': null).$whers;
|
|
|
|
|
|
|
|
$offset = $page > 1? ($page-1) * $limit: 0;
|
|
|
|
|
|
|
|
$limit_str = $limit
|
|
|
|
? $this->db->selectLimit($limit, $offset)
|
|
|
|
: '';
|
|
|
|
|
|
|
|
$sql = "SELECT " .join(', ', $f)
|
|
|
|
." FROM {$this->table} {$joins}"
|
|
|
|
.($conditions? " WHERE {$conditions}":null)
|
|
|
|
.($order? " ORDER BY {$order}": null)
|
|
|
|
.$limit_str;
|
|
|
|
|
|
|
|
$data = $this->db->all($sql);
|
|
|
|
|
|
|
|
if(!empty($this->_oneToMany))
|
|
|
|
{
|
|
|
|
$newValue = $this->_findOneToMany($data);
|
|
|
|
if(!empty($newValue))
|
|
|
|
{
|
|
|
|
$data = $newValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!empty($this->_manyToMany))
|
|
|
|
{
|
|
|
|
$newValue = $this->_findManyToMany($data);
|
|
|
|
if(!empty($newValue))
|
|
|
|
{
|
|
|
|
$data = $newValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($data as $key => $value)
|
|
|
|
{
|
|
|
|
foreach ($this->tableToModel as $key1 => $value1)
|
|
|
|
{
|
|
|
|
if (isset($data[$key][Inflector::singularize($key1)]))
|
|
|
|
{
|
|
|
|
$newData[$key][$value1] = $data[$key][Inflector::singularize($key1)];
|
|
|
|
}
|
|
|
|
}
|
2005-10-23 02:39:20 +00:00
|
|
|
}
|
|
|
|
if (!empty($newData))
|
|
|
|
{
|
|
|
|
return $newData;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return $data;
|
|
|
|
}
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
}
|
2005-09-18 13:25:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @param unknown_type $data
|
|
|
|
* @return unknown
|
|
|
|
*/
|
|
|
|
function _findOneToMany(&$data)
|
|
|
|
{
|
|
|
|
$datacheck = $data;
|
|
|
|
$original = $data;
|
|
|
|
foreach ($this->_oneToMany as $rule)
|
|
|
|
{
|
|
|
|
$count = 0;
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
list($model, $value) = $rule;
|
|
|
|
|
2005-09-18 13:25:20 +00:00
|
|
|
foreach ($datacheck as $key => $value1)
|
|
|
|
{
|
|
|
|
foreach ($value1 as $key2 => $value2)
|
2005-07-16 06:10:56 +00:00
|
|
|
{
|
2005-09-18 13:25:20 +00:00
|
|
|
if($key2 === Inflector::singularize($this->table))
|
2005-08-21 06:49:02 +00:00
|
|
|
{
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
if($this->{$model}->{$this->currentModel.'_findersql'})
|
|
|
|
{
|
|
|
|
$tmpSQL = $this->{$model}->{$this->currentModel.'_findersql'};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$oneToManyConditions = $this->parseConditions($this->{$model}->{$this->currentModel.'_conditions'});
|
|
|
|
$oneToManyOrder = $this->{$model}->{$this->currentModel.'_order'};
|
|
|
|
|
|
|
|
$tmpSQL = "SELECT {$this->{$model}->{$this->currentModel.'_fields'}} FROM {$this->{$model}->table}
|
|
|
|
WHERE ({$this->{$model}->{$this->currentModel.'_foreignkey'}}) = '{$value2['id']}'"
|
|
|
|
.($oneToManyConditions? " WHERE {$oneToManyConditions}":null)
|
|
|
|
.($oneToManyOrder? " ORDER BY {$oneToManyOrder}": null);
|
|
|
|
}
|
|
|
|
|
|
|
|
$oneToManySelect[$this->{$model}->table] = $this->db->all($tmpSQL);
|
|
|
|
|
|
|
|
if( !empty($oneToManySelect[$this->{$model}->table]) && is_array($oneToManySelect[$this->{$model}->table]))
|
2005-09-07 01:52:45 +00:00
|
|
|
{
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
$newKey = Inflector::singularize($this->{$model}->table);
|
|
|
|
foreach ($oneToManySelect[$this->{$model}->table] as $key => $value)
|
2005-08-21 06:49:02 +00:00
|
|
|
{
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
$oneToManySelect1[$newKey][$key] = $value[$newKey];
|
2005-08-21 06:49:02 +00:00
|
|
|
}
|
2005-09-18 13:25:20 +00:00
|
|
|
$merged = array_merge_recursive($data[$count],$oneToManySelect1);
|
|
|
|
$newdata[$count] = $merged;
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
unset( $oneToManySelect[$this->{$model}->table], $oneToManySelect1);
|
2005-09-18 13:25:20 +00:00
|
|
|
}
|
|
|
|
if(!empty($newdata[$count]))
|
|
|
|
{
|
|
|
|
$original[$count] = $newdata[$count];
|
2005-09-07 01:52:45 +00:00
|
|
|
}
|
2005-08-21 06:49:02 +00:00
|
|
|
}
|
2005-07-16 06:10:56 +00:00
|
|
|
}
|
2005-09-18 13:25:20 +00:00
|
|
|
$count++;
|
|
|
|
}
|
2005-10-03 04:48:00 +00:00
|
|
|
if(empty($newValue) && !empty($original))
|
2005-09-18 13:25:20 +00:00
|
|
|
{
|
|
|
|
for ($i = 0; $i< count($original); $i++)
|
2005-09-14 02:58:23 +00:00
|
|
|
{
|
2005-10-03 04:48:00 +00:00
|
|
|
$newValue[$i] = $original[$i];
|
2005-09-14 02:58:23 +00:00
|
|
|
}
|
2005-08-21 06:49:02 +00:00
|
|
|
}
|
2005-09-18 13:25:20 +00:00
|
|
|
elseif(!empty($original))
|
2005-08-21 06:49:02 +00:00
|
|
|
{
|
2005-09-18 13:25:20 +00:00
|
|
|
for ($i = 0; $i< count($original); $i++)
|
|
|
|
{
|
2005-10-03 04:48:00 +00:00
|
|
|
$newValue[$i] = array_merge($newValue[$i], $original[$i]);
|
2005-09-18 13:25:20 +00:00
|
|
|
}
|
2005-08-21 06:49:02 +00:00
|
|
|
}
|
|
|
|
}
|
2005-09-19 22:59:06 +00:00
|
|
|
if(!empty($newValue))
|
|
|
|
{
|
|
|
|
return $newValue;
|
|
|
|
}
|
2005-09-18 13:25:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @param unknown_type $data
|
|
|
|
* @return unknown
|
|
|
|
*/
|
|
|
|
function _findManyToMany(&$data)
|
|
|
|
{
|
|
|
|
$datacheck = $data;
|
|
|
|
$original = $data;
|
|
|
|
foreach ($this->_manyToMany as $rule)
|
2005-08-21 06:49:02 +00:00
|
|
|
{
|
2005-09-18 13:25:20 +00:00
|
|
|
$count = 0;
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
list($model, $value) = $rule;
|
2005-09-18 13:25:20 +00:00
|
|
|
|
|
|
|
foreach ($datacheck as $key => $value1)
|
2005-08-21 06:49:02 +00:00
|
|
|
{
|
2005-09-18 13:25:20 +00:00
|
|
|
foreach ($value1 as $key2 => $value2)
|
2005-08-21 06:49:02 +00:00
|
|
|
{
|
2005-09-18 13:25:20 +00:00
|
|
|
if($key2 === Inflector::singularize($this->table))
|
2005-08-21 06:49:02 +00:00
|
|
|
{
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
if( 0 == strncmp($key2, $this->{$model}->{$this->currentModel.'_foreignkey'}, strlen($key2)) )
|
2005-09-07 01:52:45 +00:00
|
|
|
{
|
2005-09-18 13:25:20 +00:00
|
|
|
if(!empty ($value2['id']))
|
|
|
|
{
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
if($this->{$model}->{$this->currentModel.'_findersql'})
|
|
|
|
{
|
|
|
|
$tmpSQL = $this->{$model}->{$this->currentModel.'_findersql'};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$manyToManyConditions = $this->parseConditions($this->{$model}->{$this->currentModel.'_conditions'});
|
|
|
|
$manyToManyOrder = $this->{$model}->{$this->currentModel.'_order'};
|
|
|
|
|
|
|
|
$tmpSQL = "SELECT {$this->{$model}->{$this->currentModel.'_fields'}} FROM {$this->{$model}->table}
|
|
|
|
JOIN {$this->{$model}->{$this->currentModel.'_jointable'}}
|
|
|
|
ON {$this->{$model}->{$this->currentModel.'_jointable'}}.
|
|
|
|
{$this->{$model}->{$this->currentModel.'_foreignkey'}} = '$value2[id]'
|
|
|
|
AND {$this->{$model}->{$this->currentModel.'_jointable'}}.
|
|
|
|
{$this->{$model}->{$this->currentModel.'_associationforeignkey'}} = {$this->{$model}->table} .id"
|
|
|
|
.($manyToManyConditions? " WHERE {$manyToManyConditions}":null)
|
|
|
|
.($manyToManyOrder? " ORDER BY {$manyToManyOrder}": null);
|
|
|
|
}
|
2005-09-18 13:25:20 +00:00
|
|
|
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
$manyToManySelect[$this->{$model}->table] = $this->db->all($tmpSQL);
|
2005-09-18 13:25:20 +00:00
|
|
|
}
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
if( !empty($manyToManySelect[$this->{$model}->table]) && is_array($manyToManySelect[$this->{$model}->table]))
|
2005-09-07 01:52:45 +00:00
|
|
|
{
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
$newKey = Inflector::singularize($this->{$model}->table);
|
|
|
|
foreach ($manyToManySelect[$this->{$model}->table] as $key => $value)
|
2005-09-07 01:52:45 +00:00
|
|
|
{
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
$manyToManySelect1[$newKey][$key] = $value[$newKey];
|
2005-09-07 01:52:45 +00:00
|
|
|
}
|
2005-09-18 13:25:20 +00:00
|
|
|
$merged = array_merge_recursive($data[$count],$manyToManySelect1);
|
|
|
|
$newdata[$count] = $merged;
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
unset( $manyToManySelect[$this->{$model}->table], $manyToManySelect1 );
|
2005-09-18 13:25:20 +00:00
|
|
|
}
|
|
|
|
if(!empty($newdata[$count]))
|
|
|
|
{
|
|
|
|
$original[$count] = $newdata[$count];
|
2005-09-07 01:52:45 +00:00
|
|
|
}
|
|
|
|
}
|
2005-08-21 06:49:02 +00:00
|
|
|
}
|
|
|
|
}
|
2005-09-18 13:25:20 +00:00
|
|
|
$count++;
|
|
|
|
}
|
|
|
|
if(empty($newValue2) && !empty($original))
|
|
|
|
{
|
|
|
|
for ($i = 0; $i< count($original); $i++)
|
2005-09-14 02:58:23 +00:00
|
|
|
{
|
2005-09-18 13:25:20 +00:00
|
|
|
$newValue2[$i] = $original[$i];
|
2005-09-14 02:58:23 +00:00
|
|
|
}
|
2005-09-18 13:25:20 +00:00
|
|
|
if(count($this->_manyToMany < 2))
|
2005-09-14 02:58:23 +00:00
|
|
|
{
|
2005-09-18 13:25:20 +00:00
|
|
|
$newValue = $newValue2;
|
2005-09-14 02:58:23 +00:00
|
|
|
}
|
2005-08-21 06:49:02 +00:00
|
|
|
}
|
2005-09-18 13:25:20 +00:00
|
|
|
elseif(!empty($original))
|
2005-08-21 06:49:02 +00:00
|
|
|
{
|
2005-09-18 13:25:20 +00:00
|
|
|
for ($i = 0; $i< count($original); $i++)
|
|
|
|
{
|
|
|
|
$newValue[$i] = array_merge($newValue2[$i], $original[$i]);
|
|
|
|
}
|
2005-08-21 06:49:02 +00:00
|
|
|
}
|
|
|
|
}
|
2005-09-19 22:59:06 +00:00
|
|
|
if(!empty($newValue))
|
|
|
|
{
|
|
|
|
return $newValue;
|
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
2005-09-18 13:25:20 +00:00
|
|
|
|
2005-06-23 13:59:02 +00:00
|
|
|
/**
|
|
|
|
* Returns an array of all rows for given SQL statement.
|
|
|
|
*
|
|
|
|
* @param string $sql SQL query
|
|
|
|
* @return array
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
function findBySql ($sql)
|
|
|
|
{
|
2005-10-28 08:25:31 +00:00
|
|
|
$data = $this->db->all($sql);
|
|
|
|
foreach ($data as $key => $value)
|
|
|
|
{
|
|
|
|
foreach ($this->tableToModel as $key1 => $value1)
|
|
|
|
{
|
|
|
|
if (isset($data[$key][Inflector::singularize($key1)]))
|
|
|
|
{
|
|
|
|
$newData[$key][$value1] = $data[$key][Inflector::singularize($key1)];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!empty($newData))
|
|
|
|
{
|
|
|
|
return $newData;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return $data;
|
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns number of rows matching given SQL condition.
|
|
|
|
*
|
|
|
|
* @param string $conditions SQL conditions (WHERE clause conditions)
|
|
|
|
* @return int Number of matching rows
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
function findCount ($conditions)
|
|
|
|
{
|
2005-08-21 06:49:02 +00:00
|
|
|
list($data) = Model::findAll($conditions, 'COUNT(*) AS count');
|
2005-09-07 01:52:45 +00:00
|
|
|
return isset($data[0]['count'])? $data[0]['count']: false;
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @param string $conditions SQL conditions (WHERE clause conditions)
|
|
|
|
* @param unknown_type $fields
|
|
|
|
* @return unknown
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
function findAllThreaded ($conditions=null, $fields=null, $sort=null)
|
|
|
|
{
|
2005-08-21 06:49:02 +00:00
|
|
|
return $this->_doThread(Model::findAll($conditions, $fields, $sort), null);
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @param unknown_type $data
|
|
|
|
* @param unknown_type $root NULL or id for root node of operation
|
|
|
|
* @return array
|
2005-07-04 04:16:20 +00:00
|
|
|
* @access private
|
2005-06-23 13:59:02 +00:00
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
function _doThread ($data, $root)
|
|
|
|
{
|
|
|
|
$out = array();
|
|
|
|
|
|
|
|
for ($ii=0; $ii<sizeof($data); $ii++)
|
|
|
|
{
|
|
|
|
if ($data[$ii]['parent_id'] == $root)
|
|
|
|
{
|
|
|
|
$tmp = $data[$ii];
|
|
|
|
$tmp['children'] = isset($data[$ii]['id'])? $this->_doThread($data, $data[$ii]['id']): null;
|
|
|
|
$out[] = $tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $out;
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array with keys "prev" and "next" that holds the id's of neighbouring data,
|
|
|
|
* which is useful when creating paged lists.
|
|
|
|
*
|
|
|
|
* @param string $conditions SQL conditions for matching rows
|
|
|
|
* @param unknown_type $field
|
|
|
|
* @param unknown_type $value
|
|
|
|
* @return array Array with keys "prev" and "next" that holds the id's
|
|
|
|
*/
|
2005-10-22 21:34:17 +00:00
|
|
|
function findNeighbours ($conditions, $field, $value)
|
|
|
|
{
|
|
|
|
@list($prev) = Model::findAll($conditions." AND {$field} < '{$value}'", $field, "{$field} DESC", 1);
|
|
|
|
@list($next) = Model::findAll($conditions." AND {$field} > '{$value}'", $field, "{$field} ASC", 1);
|
|
|
|
|
|
|
|
$prev = isset($prev) ? $prev: false;
|
|
|
|
$next = isset($next) ? $next: false;
|
|
|
|
return array('prev'=>$prev, 'next'=>$next);
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a resultset for given SQL statement.
|
|
|
|
*
|
|
|
|
* @param string $sql SQL statement
|
|
|
|
* @return array Resultset
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
function query ($sql)
|
|
|
|
{
|
|
|
|
return $this->db->query($sql);
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if all fields pass validation.
|
|
|
|
*
|
|
|
|
* @param array $data POST data
|
|
|
|
* @return boolean True if there are no errors
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
function validates ($data=null)
|
|
|
|
{
|
|
|
|
$errors = count($this->invalidFields($data? $data: $this->data));
|
|
|
|
|
|
|
|
return $errors == 0;
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array of invalid fields.
|
|
|
|
*
|
|
|
|
* @param array $data Posted data
|
|
|
|
* @return array Array of invalid fields
|
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
function invalidFields ($data=null)
|
|
|
|
{
|
|
|
|
return $this->_invalidFields($data);
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array of invalid fields.
|
|
|
|
*
|
|
|
|
* @param array $data
|
|
|
|
* @return array Array of invalid fields
|
2005-07-04 04:16:20 +00:00
|
|
|
* @access private
|
2005-06-23 13:59:02 +00:00
|
|
|
*/
|
2005-07-10 05:08:19 +00:00
|
|
|
function _invalidFields ($data=null)
|
|
|
|
{
|
|
|
|
if (!isset($this->validate))
|
2005-07-16 06:10:56 +00:00
|
|
|
{
|
2005-07-10 05:08:19 +00:00
|
|
|
return true;
|
2005-07-16 06:10:56 +00:00
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
if (is_array($this->validationErrors))
|
2005-07-16 06:10:56 +00:00
|
|
|
{
|
2005-07-10 05:08:19 +00:00
|
|
|
return $this->validationErrors;
|
2005-07-16 06:10:56 +00:00
|
|
|
}
|
|
|
|
|
2005-07-10 05:08:19 +00:00
|
|
|
$data = ($data? $data: (isset($this->data)? $this->data: array()));
|
|
|
|
$errors = array();
|
2005-10-18 22:27:39 +00:00
|
|
|
foreach ($data as $table => $field)
|
2005-07-10 05:08:19 +00:00
|
|
|
{
|
|
|
|
foreach ($this->validate as $field_name=>$validator)
|
|
|
|
{
|
2005-08-25 23:23:44 +00:00
|
|
|
if (isset($data[$table][$field_name]) && !preg_match($validator, $data[$table][$field_name]))
|
2005-07-16 06:10:56 +00:00
|
|
|
{
|
|
|
|
$errors[$field_name] = 1;
|
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
|
|
|
$this->validationErrors = $errors;
|
|
|
|
return $errors;
|
|
|
|
}
|
|
|
|
}
|
2005-08-21 06:49:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function determines whether or not a string is a foreign key
|
|
|
|
*
|
|
|
|
* @param string $field Returns true if the input string ends in "_id"
|
2005-08-25 16:40:50 +00:00
|
|
|
* @return True if the field is a foreign key listed in the belongsTo array.
|
2005-08-21 06:49:02 +00:00
|
|
|
*/
|
2005-08-25 16:40:50 +00:00
|
|
|
function isForeignKey( $field )
|
|
|
|
{
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
$foreignKeys = array();
|
2005-08-25 16:40:50 +00:00
|
|
|
|
|
|
|
if(!empty($this->_belongsToOther))
|
|
|
|
{
|
|
|
|
|
|
|
|
foreach ($this->_belongsToOther as $rule)
|
|
|
|
{
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
list($model, $value) = $rule;
|
|
|
|
$foreignKeys[$this->{$model}->{$this->currentModel.'_foreignkey'}] = $this->{$model}->{$this->currentModel.'_foreignkey'};
|
2005-08-25 16:40:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( array_key_exists($field, $foreignKeys) )
|
2005-08-24 03:08:37 +00:00
|
|
|
{
|
2005-08-21 06:49:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-09-18 13:25:20 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @return unknown
|
|
|
|
*/
|
2005-08-21 06:49:02 +00:00
|
|
|
function getDisplayField()
|
|
|
|
{
|
|
|
|
// $displayField defaults to 'name'
|
|
|
|
$dispField = 'name';
|
2005-06-23 13:59:02 +00:00
|
|
|
|
2005-08-21 06:49:02 +00:00
|
|
|
// If the $displayField variable is set in this model, use it.
|
|
|
|
if( isset( $this->displayField ) ) {
|
|
|
|
$dispField = $this->displayField;
|
|
|
|
}
|
|
|
|
|
|
|
|
// And if the display field does not exist in the table info structure, use the ID field.
|
|
|
|
if( false == $this->hasField( $dispField ) )
|
|
|
|
$dispField = 'id';
|
|
|
|
|
|
|
|
return $dispField;
|
|
|
|
}
|
2005-09-07 01:52:45 +00:00
|
|
|
|
2005-09-18 13:25:20 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @return unknown
|
|
|
|
*/
|
2005-09-07 01:52:45 +00:00
|
|
|
function getLastInsertID()
|
|
|
|
{
|
|
|
|
return $this->db->lastInsertId($this->table, 'id');
|
|
|
|
}
|
2005-09-17 12:37:05 +00:00
|
|
|
|
2005-09-18 13:25:20 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @param unknown_type $tableName
|
|
|
|
*/
|
|
|
|
function _throwMissingTable($tableName)
|
2005-09-17 12:37:05 +00:00
|
|
|
{
|
2005-10-03 04:48:00 +00:00
|
|
|
$error =& new AppController();
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
$error->missingTable = $this->table;
|
2005-09-18 13:25:20 +00:00
|
|
|
call_user_func_array(array(&$error, 'missingTable'), $tableName);
|
2005-09-17 12:37:05 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2005-09-18 13:25:20 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
*/
|
2005-09-17 12:37:05 +00:00
|
|
|
function _throwMissingConnection()
|
|
|
|
{
|
2005-10-03 04:48:00 +00:00
|
|
|
$error =& new AppController();
|
[1159]
Author: phpnut
Date: 1:39:26 PM, Saturday, October 22, 2005
Message:
Just about done with refactoring the model class.
This should be tested to make sure all changes are working as expected.
[1158]
Author: phpnut
Date: 5:34:41 AM, Saturday, October 22, 2005
Message:
More work on associations.
Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany
[1157]
Author: phpnut
Date: 3:39:13 AM, Saturday, October 22, 2005
Message:
More cleanup in Model class.
[1156]
Author: phpnut
Date: 2:43:38 AM, Saturday, October 22, 2005
Message:
Removing duplicate code the the associations.
Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code.
[1155]
Author: phpnut
Date: 1:52:47 AM, Saturday, October 22, 2005
Message:
More cleaning up of the model class
[1154]
Author: phpnut
Date: 1:40:34 AM, Saturday, October 22, 2005
Message:
Cleaning up code layout
[1153]
Author: phpnut
Date: 1:32:05 AM, Saturday, October 22, 2005
Message:
removing temp variables and extra calls to Inflector::underscore();
[1152]
Author: phpnut
Date: 1:22:58 AM, Saturday, October 22, 2005
Message:
More work on associations.
Removing code that is no longer needed.
[1151]
Author: phpnut
Date: 12:02:43 AM, Saturday, October 22, 2005
Message:
more work on associations
[1150]
Author: phpnut
Date: 6:25:45 PM, Friday, October 21, 2005
Message:
more refactoring of associations
[1149]
Author: phpnut
Date: 6:04:18 PM, Friday, October 21, 2005
Message:
refactoring model and adding more association code
[1145]
Author: phpnut
Date: 2:43:05 PM, Thursday, October 20, 2005
Message:
more refactoring on associations
[1143]
Author: phpnut
Date: 1:44:42 PM, Thursday, October 20, 2005
Message:
Refactoring associations code.
Starting work allowing full use of associations array settings
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
|
|
|
$error->missingConnection = $this->name;
|
2005-09-17 12:37:05 +00:00
|
|
|
call_user_func_array(array(&$error, 'missingConnection'), null);
|
|
|
|
exit;
|
|
|
|
}
|
2005-06-23 13:59:02 +00:00
|
|
|
}
|
|
|
|
|
2005-05-15 21:41:38 +00:00
|
|
|
?>
|