Permalink
Browse files

BackwardsCompatibilityBreak - removed support for date function trans…

…lation in fDatabase/fSQLTranslation.

InternalBackwardsCompatibilityBreak - Removed fORMDatabase::addTableToKeys(), fORMDatabase::addTableToValues(), fORMDatabase::escapeBySchema() and fORMDatabase::escapeByType(); rewrote fORMDatabase::createHavingClause() to fORMDatabase::addHavingClause(); rewrote fORMDatabase::createOrderByClause() to fORMDatabase::addOrderByClause(); rewrote fORMDatabase::insertFromAndGroupByClauses() to fORMDatabase::injectFromAndGroupByClauses(); added the `$schema` parameter to the beginning of fORMSchema::getRouteName(), fORMSchema::getRouteName(), fORMSchema::getRoutes() and fORMSchema::isOneToOne(); added the `$class` parameter to the beginning of fORMRelated::storeManyToMany().

Fixed tickets #319 and #308. Rewrote the ORM to use quoted identifiers and placeholder escaping. Added support for PostgreSQL, Oracle and SQL Server schemas.

Added tests for fActiveRecord, fRecordSet, fORMRelated and fORMOrdering
  • Loading branch information...
wbond committed Oct 22, 2009
1 parent 855bde9 commit 30b776544b0911a857ab87a4a62797c18a2329b8
Showing with 2,060 additions and 1,687 deletions.
  1. +172 −107 classes/fActiveRecord.php
  2. +286 −123 classes/fDatabase.php
  3. +27 −17 classes/fORMColumn.php
  4. +523 −508 classes/fORMDatabase.php
  5. +208 −90 classes/fORMOrdering.php
  6. +166 −107 classes/fORMRelated.php
  7. +50 −29 classes/fORMSchema.php
  8. +90 −45 classes/fORMValidation.php
  9. +213 −154 classes/fRecordSet.php
  10. +99 −215 classes/fSQLTranslation.php
  11. +226 −292 classes/fSchema.php
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -9,7 +9,8 @@
* @package Flourish
* @link http://flourishlib.com/fORMColumn
*
* @version 1.0.0b5
* @version 1.0.0b6
* @changes 1.0.0b6 Changed SQL statements to use value placeholders, identifier escaping and schema support [wb, 2009-10-22]
* @changes 1.0.0b5 Updated to use new fORM::registerInspectCallback() method [wb, 2009-07-13]
* @changes 1.0.0b4 Updated code for new fORM API [wb, 2009-06-15]
* @changes 1.0.0b3 Updated code to use new fValidationException::formatField() method [wb, 2009-06-04]
@@ -99,7 +100,8 @@ static public function configureEmailColumn($class, $column)
{
$class = fORM::getClass($class);
$table = fORM::tablize($class);
$data_type = fORMSchema::retrieve()->getColumnInfo($table, $column, 'type');
$schema = fORMSchema::retrieve();
$data_type = $schema->getColumnInfo($table, $column, 'type');
$valid_data_types = array('varchar', 'char', 'text');
if (!in_array($data_type, $valid_data_types)) {
@@ -136,7 +138,8 @@ static public function configureLinkColumn($class, $column)
{
$class = fORM::getClass($class);
$table = fORM::tablize($class);
$data_type = fORMSchema::retrieve()->getColumnInfo($table, $column, 'type');
$schema = fORMSchema::retrieve();
$data_type = $schema->getColumnInfo($table, $column, 'type');
$valid_data_types = array('varchar', 'char', 'text');
if (!in_array($data_type, $valid_data_types)) {
@@ -180,7 +183,8 @@ static public function configureNumberColumn($class, $column)
{
$class = fORM::getClass($class);
$table = fORM::tablize($class);
$data_type = fORMSchema::retrieve()->getColumnInfo($table, $column, 'type');
$schema = fORMSchema::retrieve();
$data_type = $schema->getColumnInfo($table, $column, 'type');
$valid_data_types = array('integer', 'float');
if (!in_array($data_type, $valid_data_types)) {
@@ -231,7 +235,8 @@ static public function configureRandomColumn($class, $column, $type, $length)
{
$class = fORM::getClass($class);
$table = fORM::tablize($class);
$data_type = fORMSchema::retrieve()->getColumnInfo($table, $column, 'type');
$schema = fORMSchema::retrieve();
$data_type = $schema->getColumnInfo($table, $column, 'type');
$valid_data_types = array('varchar', 'char', 'text');
if (!in_array($data_type, $valid_data_types)) {
@@ -298,7 +303,9 @@ static public function encodeNumberColumn($object, &$values, &$old_values, &$rel
list ($action, $column) = fORM::parseMethod($method_name);
$class = get_class($object);
$column_info = fORMSchema::retrieve()->getColumnInfo(fORM::tablize($class), $column);
$schema = fORMSchema::retrieve();
$table = fORM::tablize($class);
$column_info = $schema->getColumnInfo($table, $column);
$value = $values[$column];
if ($value instanceof fNumber) {
@@ -332,24 +339,24 @@ static public function generate($object, &$values, &$old_values, &$related_recor
{
list ($action, $column) = fORM::parseMethod($method_name);
$class = get_class($object);
$table = fORM::tablize($class);
$class = get_class($object);
$table = fORM::tablize($class);
$schema = fORMSchema::retrieve();
$db = fORMDatabase::retrieve();
$settings = self::$random_columns[$class][$column];
// Check to see if this is a unique column
$unique_keys = fORMSchema::retrieve()->getKeys($table, 'unique');
$unique_keys = $schema->getKeys($table, 'unique');
$is_unique_column = FALSE;
foreach ($unique_keys as $unique_key) {
if ($unique_key == array($column)) {
$is_unique_column = TRUE;
$sql = "SELECT %r FROM %r WHERE %r = %s";
do {
$value = fCryptography::randomString($settings['length'], $settings['type']);
// See if this is unique
$sql = "SELECT " . $column . " FROM " . $table . " WHERE " . $column . " = " . fORMDatabase::retrieve()->escape('string', $value);
} while (fORMDatabase::retrieve()->query($sql)->countReturnedRows());
} while ($db->query($sql, $column, $table, $column, $value)->countReturnedRows());
}
}
@@ -472,7 +479,9 @@ static public function prepareNumberColumn($object, &$values, &$old_values, &$re
list ($action, $column) = fORM::parseMethod($method_name);
$class = get_class($object);
$column_info = fORMSchema::retrieve()->getColumnInfo(fORM::tablize($class), $column);
$table = fORM::tablize($class);
$schema = fORMSchema::retrieve();
$column_info = $schema->getColumnInfo($table, $column);
$value = $values[$column];
if ($value instanceof fNumber) {
@@ -527,11 +536,12 @@ static public function reflect($class, &$signatures, $include_doc_comments)
if (isset(self::$number_columns[$class])) {
$table = fORM::tablize($class);
$table = fORM::tablize($class);
$schema = fORMSchema::retrieve();
foreach(self::$number_columns[$class] as $column => $enabled) {
$camelized_column = fGrammar::camelize($column, TRUE);
$type = fORMSchema::retrieve()->getColumnInfo($table, $column, 'type');
$type = $schema->getColumnInfo($table, $column, 'type');
// Get and set methods
$signature = '';
Oops, something went wrong.

0 comments on commit 30b7765

Please sign in to comment.