Permalink
Browse files

BackwardsCompatibilityBreak - Removed ability to preload related reco…

…rds for a record set due to ever increasing complexity
  • Loading branch information...
wbond committed Jul 4, 2008
1 parent fb8ef2f commit 1fd0f7c49f3101a5a8e80443fa72ef5dd2ebb918
@@ -70,7 +70,7 @@ public function __call($method_name, $parameters)
}
// This will prevent quiet failure
if (($action == 'set' || $action == 'associate' || $action == 'inject') && sizeof($parameters) < 1) {
if (($action == 'set' || $action == 'associate') && sizeof($parameters) < 1) {
fCore::toss(
'fProgrammerException',
fGrammar::compose(
@@ -137,15 +137,6 @@ public function __call($method_name, $parameters)
}
return fORMRelated::constructRecord($this, $this->values, $subject);
case 'inject':
$subject = fGrammar::singularize($subject);
$subject = fGrammar::camelize($subject, TRUE);
if (isset($parameters[1])) {
return fORMRelated::setRecords($this, $this->related_records, $subject, $parameters[0], $parameters[1]);
}
return fORMRelated::setRecords($this, $this->related_records, $subject, $parameters[0]);
case 'link':
$subject = fGrammar::singularize($subject);
$subject = fGrammar::camelize($subject, TRUE);
@@ -487,19 +487,16 @@ static public function registerHookCallback($class, $hook, $callback)
);
static $invalid_replace_hooks = array(
'replace::enableDebugging()',
'replace::assign()',
'replace::configure()',
'replace::constructInsertSQL()',
'replace::constructPrimaryKeyWhereClause()',
'replace::constructUpdateSQL()',
'replace::entify()',
'replace::format()',
'replace::enableDebugging()',
'replace::encode()',
'replace::get()',
'replace::loadFromIdentityMap()',
'replace::loadFromResult()',
'replace::retrieve()',
'replace::storeManyToManyAssociations()',
'replace::storeOneToManyRelatedRecords()'
'replace::prepare()',
'replace::set()'
);
if (!in_array($hook, $valid_hooks) && !$replace_hook) {
@@ -378,84 +378,6 @@ static public function createPrimaryKeyWhereClause($table, $table_alias, &$value
}
/**
* Creates a where clause condition for primary keys of the table specified
*
* This method requires the $primary_keys parameter to be one of:
*
* - A scalar value for a single-column primary key
* - An array of values for a single-column primary key
* - An associative array of values for a multi-column primary key (column => value)
* - An array of associative arrays of values for a multi-column primary key (key => array(column => value)
*
* If you are looking to build a primary key where clause from the $values
* and $old_values arrays, please see {@link createPrimaryKeyWhereClause()}
*
* @throws fValidationException
* @internal
*
* @param string $table The table to build the where clause condition for
* @param string $table_alias The alias for the table
* @param mixed $primary_keys The primary key or keys to use in building the condition
* @return string A single WHERE clause condition (possibly in parentheses) representing the primary keys provided
*/
static public function createPrimaryKeyWhereCondition($table, $table_alias, $primary_keys)
{
$sql = '';
$primary_key_fields = fORMSchema::getInstance()->getKeys($table, 'primary');
// We have a multi-field primary key, making things kinda ugly
if (sizeof($primary_key_fields) > 1) {
// If the multi-field primary key is just a single primary key we'll convert it so we don't need lots of conditional code to generate SQL
if (!isset($primary_keys[0])) {
$primary_keys = array($primary_keys);
}
$sql .= '((';
$first = TRUE;
foreach ($primary_keys as $primary_key) {
if (!$first) {
$sql .= ') OR (';
}
for ($i=0; $i < sizeof($primary_key_fields); $i++) {
$field = $primary_key_fields[$i];
if ($i) {
$sql .= ' AND ';
}
$sql .= $table_alias . '.' . $field;
$sql .= fORMDatabase::prepareBySchema($table, $field, $primary_key[$field], '=');
}
$first = FALSE;
}
$sql .= '))';
// We have a single primary key field, making things nice and easy
} else {
$primary_key_field = $primary_key_fields[0];
// If we don't have an array of primary keys, just return a regular equation comparison
if (!is_array($primary_keys)) {
return $table_alias . '.' . $primary_key_field . fORMDatabase::prepareBySchema($table, $primary_key_field, $primary_keys, '=');
}
$sql .= $table_alias . '.' . $primary_key_field . ' IN (';
$first = TRUE;
foreach ($primary_keys as $primary_key) {
if (!$first) {
$sql .= ', ';
}
$sql .= fORMDatabase::prepareBySchema($table, $primary_key_field, $primary_key);
$first = FALSE;
}
$sql .= ')';
}
return $sql;
}
/**
* Creates a where clause from an array of conditions
*
@@ -372,16 +372,14 @@ static public function setOrderBys($class, $related_class, $route, $order_bys)
/**
* Sets the related records for many-to-many relationships
*
* @internal
*
* @param mixed $class The class name or instance of the class to get the related values for
* @param array &$related_records The related records existing for the {@link fActiveRecord} class
* @param string $related_class The class we are associating with the current record
* @param fRecordSet $records The records are associating
* @param string $route The route to use between the current class and the related class
* @return void
*/
static public function setRecords($class, &$related_records, $related_class, fRecordSet $records, $route=NULL)
static private function setRecords($class, &$related_records, $related_class, fRecordSet $records, $route=NULL)
{
$table = fORM::tablize($class);
$related_table = fORM::tablize($related_class);
Oops, something went wrong.

0 comments on commit 1fd0f7c

Please sign in to comment.