So I started from scratch and eliminated a lot of unnecessary code in the Model and has updated my first post with the revised code. Everything is working great, except I am getting two separate error messages when I attempt to upload images as as ThumbnailImage and as an Attachment.
ThumbnailImage upload error:
[User Error] Couldn't run query: SELECT `File`.*, `Gallery`.*, `File`.ID, if(`File`.ClassName,`File`.ClassName,'File') AS RecordClassName FROM `File` LEFT JOIN `Gallery` ON `Gallery`.ID = `File`.ID WHERE (`File`.`ID` = 1) ORDER BY SortOrder ASC LIMIT 1 Column 'SortOrder' in order clause is ambiguous
GET /public_html/jonathandbaker.com/images/iframe/Project/15/Thumbnail
Line 401 in D:\xampp\xampp\htdocs\public_html\jonathandbaker.com\sapphire\core\model\MySQLDatabase.php
Source
392 }
393
394 function databaseError($msg, $errorLevel = E_USER_ERROR) {
395 // try to extract and format query
396 if(preg_match('/Couldn\'t run query: ([^\|]*)\|\s*(.*)/', $msg, $matches)) {
397 $formatter = new SQLFormatter();
398 $msg = "Couldn't run query: \n" . $formatter->formatPlain($matches[1]) . "\n\n" . $matches[2];
399 }
400
401 user_error($msg, $errorLevel);
402 }
403 }
404
405 /**
406 * A result-set from a MySQL database.
407 * @package sapphire
Trace
* Couldn't run query: SELECT `File`.*, `Gallery`.*, `File`.ID, if(`File`.ClassName,`File`.ClassName,'File') AS RecordClassName FROM `File` LEFT JOIN `Gallery` ON `Gallery`.ID = `File`.ID WHERE (`File`.`ID` = 1) ORDER BY SortOrder ASC LIMIT 1 Column 'SortOrder' in order clause is ambiguous
Line 401 of MySQLDatabase.php
* MySQLDatabase->databaseError(Couldn't run query: SELECT `File`.*, `Gallery`.*, `File`.ID, if(`File`.ClassName,`File`.ClassName,'File') AS RecordClassName FROM `File` LEFT JOIN `Gallery` ON `Gallery`.ID = `File`.ID WHERE (`File`.`ID` = 1) ORDER BY SortOrder ASC LIMIT 1 | Column 'SortOrder' in order clause is ambiguous,256)
Line 102 of MySQLDatabase.php
* MySQLDatabase->query(SELECT `File`.*, `Gallery`.*, `File`.ID, if(`File`.ClassName,`File`.ClassName,'File') AS RecordClassName FROM `File` LEFT JOIN `Gallery` ON `Gallery`.ID = `File`.ID WHERE (`File`.`ID` = 1) ORDER BY SortOrder ASC LIMIT 1,256)
Line 120 of DB.php
* DB::query(SELECT `File`.*, `Gallery`.*, `File`.ID, if(`File`.ClassName,`File`.ClassName,'File') AS RecordClassName FROM `File` LEFT JOIN `Gallery` ON `Gallery`.ID = `File`.ID WHERE (`File`.`ID` = 1) ORDER BY SortOrder ASC LIMIT 1)
Line 426 of SQLQuery.php
* SQLQuery->execute()
Line 2531 of DataObject.php
* DataObject->instance_get_one(`File`.`ID` = 1,)
Line 2468 of DataObject.php
* DataObject::get_one(File,`File`.`ID` = 1)
Line 2563 of DataObject.php
* DataObject::get_by_id(File,1)
Line 1045 of DataObject.php
* DataObject->getComponent(Parent)
* call_user_func_array(Array,Array)
Line 565 of Object.php
* Object->__call(Parent,Array)
* Crop_Thumbnail->Parent()
Line 279 of Image.php
* Image->cacheFilename(CMSThumbnail,,)
Line 261 of Image.php
* Image->getFormattedImage(CMSThumbnail)
Line 211 of Image.php
* Image->CMSThumbnail()
* call_user_func_array(Array,Array)
Line 408 of ViewableData.php
* ViewableData->XML_val(CMSThumbnail,,1)
Line 56 of .cacheD..xampp.xampp.htdocs.public_html.jonathandbaker.com.sapphire.templates.Image_iframe.ss
* include(C:\Windows\Temp\silverstripe-cacheD--xampp-xampp-htdocs-public_html-jonathandbaker.com\.cacheD..xampp.xampp.htdocs.public_html.jonathandbaker.com.sapphire.templates.Image_iframe.ss)
Line 357 of SSViewer.php
* SSViewer->process(ViewableData_Customised)
Line 163 of Controller.php
* Controller->handleAction(HTTPRequest)
Line 129 of RequestHandler.php
* RequestHandler->handleRequest(HTTPRequest)
Line 119 of Controller.php
* Controller->handleRequest(HTTPRequest)
Line 277 of Director.php
* Director::handleRequest(HTTPRequest,Session)
Line 121 of Director.php
* Director::direct(/images/iframe/Project/15/Thumbnail)
Line 118 of main.php
Attachment upload error:
[Warning] Unknown class passed as parameter
POST /public_html/jonathandbaker.com/images/index/Attachment/5/AttachmentImage/EditImageForm
Line 445 in D:\xampp\xampp\htdocs\public_html\jonathandbaker.com\sapphire\core\Object.php
Source
436 * Prepare static variables before processing a {@link get_static} or {@link set_static}
437 * call.
438 */
439 private static function prepare_statics($class) {
440 // _cache_statics_prepared setting must come first to prevent infinite loops when we call
441 // get_static below
442 self::$_cache_statics_prepared[$class] = true;
443
444 // load statics now for DataObject classes
445 if(is_subclass_of($class, 'DataObject')) {
446 $extensions = Object::uninherited_static($class, 'extensions');
447 if($extensions) foreach($extensions as $extension) {
448 if(preg_match('/^([^(]*)/', $extension, $matches)) {
449 $extensionClass = $matches[1];
450 DataObjectDecorator::load_extra_statics($class, $extensionClass);
451 }
Trace
* is_subclass_of(Crop_Thumbnail,DataObject)
Line 445 of Object.php
* Object::prepare_statics(Crop_Thumbnail)
Line 269 of Object.php
* Object::uninherited_static(Crop_Thumbnail,db)
Line 2020 of DataObject.php
* DataObject::has_own_table(Crop_Thumbnail)
Line 89 of ClassInfo.php
* ClassInfo::dataClassesFor(Image)
Line 2258 of DataObject.php
* DataObject->buildSQL(,,,,1,)
Line 2350 of DataObject.php
* DataObject->extendedSQL(,,,,)
Line 566 of File.php
* File->instance_get(,,,,DataObjectSet)
Line 2387 of DataObject.php
* DataObject::get(Image)
Line 58 of SortableDataObject.php
* SortableDataObject->onBeforeWrite(,,,,,,)
Line 802 of Object.php
* Object->extend(onBeforeWrite,)
Line 665 of DataObject.php
* DataObject->onBeforeWrite()
Line 251 of File.php
* File->onBeforeWrite()
Line 783 of DataObject.php
* DataObject->write()
Line 133 of Upload.php
* Upload->load(Array,)
Line 151 of Upload.php
* Upload->loadIntoFile(Array,Image)
Line 226 of File.php
* File->loadUploaded(Array)
Line 123 of Image.php
* Image->loadUploaded(Array)
Line 748 of Image.php
* Image_Uploader->save(Array,Form,HTTPRequest)
Line 241 of Form.php
* Form->httpSubmission(HTTPRequest)
Line 129 of RequestHandler.php
* RequestHandler->handleRequest(HTTPRequest)
Line 143 of RequestHandler.php
* RequestHandler->handleRequest(HTTPRequest)
Line 119 of Controller.php
* Controller->handleRequest(HTTPRequest)
Line 277 of Director.php
* Director::handleRequest(HTTPRequest,Session)
Line 121 of Director.php
* Director::direct(/images/index/Attachment/5/AttachmentImage/EditImageForm)
Line 118 of main.php