Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Silverstripe (3.1.13-rc1) doesnt write in the database


Go to End


4 Posts   2678 Views

Avatar
HermannDettmann

Community Member, 3 Posts

2 September 2015 at 11:05am

Edited: 02/09/2015 11:06am

Dear Silverstripers,

i'm struggling with a weird issue that only appears on my live machine and
not on my local machine. I added some fields in mysite/code/ProjectPage.php
and run dev/build. On my local machine Silverstripe adds the fields to the database.
If I deploy ProjectPage.php to my live machine and run dev/build Silverstripe gives
me the message that all fields were added successfully but then I go back on my
home page I get the following:

[User Error] Couldn't run query: SELECT DISTINCT "SiteTree_Live"."ClassName", "SiteTree_Live"."Created", "SiteTree_Live"."LastEdited", "SiteTree_Live"."ID", CASE WHEN "SiteTree_Live"."ClassName" IS NOT NULL THEN "SiteTree_Live"."ClassName" ELSE 'SiteTree' END AS "RecordClassName", "SiteTree_Live"."Sort" FROM "SiteTree_Live" WHERE ("ProjectPage"."ID" = 7) AND ("SiteTree_Live"."ClassName" IN ('ProjectPage')) ORDER BY "SiteTree_Live"."Sort" ASC LIMIT 1 Unknown column 'ProjectPage.ID' in 'where clause'
GET /
Line 598 in /www/htdocs/w00c0dec/new.hermanndettmann.com/framework/model/MySQLDatabase.php
Source
589 	}
590 
591 	public function databaseError($msg, $errorLevel = E_USER_ERROR) {
592 		// try to extract and format query
593 		if(preg_match('/Couldn\'t run query: ([^\|]*)\|\s*(.*)/', $msg, $matches)) {
594 			$formatter = new SQLFormatter();
595 			$msg = "Couldn't run query: \n" . $formatter->formatPlain($matches[1]) . "\n\n" . $matches[2];
596 		}
597 
598 		user_error($msg, $errorLevel);
599 	}
600 
601 	/**
602 	 * Return a boolean type-formatted string
603 	 *
604 	 * @param array $values Contains a tokenised list of info about this data type
Trace
Couldn't run query: SELECT DISTINCT "SiteTree_Live"."ClassName", "SiteTree_Live"."Created", "SiteTree_Live"."LastEdited", "SiteTree_Live"."ID", CASE WHEN "SiteTree_Live"."ClassName" IS NOT NULL THEN "SiteTree_Live"."ClassName" ELSE 'SiteTree' END AS "RecordClassName", "SiteTree_Live"."Sort" FROM "SiteTree_Live" WHERE ("ProjectPage"."ID" = 7) AND ("SiteTree_Live"."ClassName" IN ('ProjectPage')) ORDER BY "SiteTree_Live"."Sort" ASC LIMIT 1 Unknown column 'ProjectPage.ID' in 'where clause' 
MySQLDatabase.php:598
MySQLDatabase->databaseError(Couldn't run query: SELECT DISTINCT "SiteTree_Live"."ClassName", "SiteTree_Live"."Created", "SiteTree_Live"."LastEdited", "SiteTree_Live"."ID", CASE WHEN "SiteTree_Live"."ClassName" IS NOT NULL THEN "SiteTree_Live"."ClassName" ELSE 'SiteTree' END AS "RecordClassName", "SiteTree_Live"."Sort" FROM "SiteTree_Live" WHERE ("ProjectPage"."ID" = 7) AND ("SiteTree_Live"."ClassName" IN ('ProjectPage')) ORDER BY "SiteTree_Live"."Sort" ASC LIMIT 1 | Unknown column 'ProjectPage.ID' in 'where clause',256) 
MySQLDatabase.php:150
MySQLDatabase->query(SELECT DISTINCT "SiteTree_Live"."ClassName", "SiteTree_Live"."Created", "SiteTree_Live"."LastEdited", "SiteTree_Live"."ID", CASE WHEN "SiteTree_Live"."ClassName" IS NOT NULL THEN "SiteTree_Live"."ClassName" ELSE 'SiteTree' END AS "RecordClassName", "SiteTree_Live"."Sort" FROM "SiteTree_Live" WHERE ("ProjectPage"."ID" = 7) AND ("SiteTree_Live"."ClassName" IN ('ProjectPage')) ORDER BY "SiteTree_Live"."Sort" ASC LIMIT 1,256) 
DB.php:208
DB::query(SELECT DISTINCT "SiteTree_Live"."ClassName", "SiteTree_Live"."Created", "SiteTree_Live"."LastEdited", "SiteTree_Live"."ID", CASE WHEN "SiteTree_Live"."ClassName" IS NOT NULL THEN "SiteTree_Live"."ClassName" ELSE 'SiteTree' END AS "RecordClassName", "SiteTree_Live"."Sort" FROM "SiteTree_Live" WHERE ("ProjectPage"."ID" = 7) AND ("SiteTree_Live"."ClassName" IN ('ProjectPage')) ORDER BY "SiteTree_Live"."Sort" ASC LIMIT 1,256) 
SQLQuery.php:951
SQLQuery->execute() 
DataQuery.php:327
DataQuery->execute() 
DataObject.php:2209
DataObject->loadLazyFields(ProjectPage) 
DataObject.php:2127
DataObject->getField(TeaserImageID) 
DataObject.php:1419
DataObject->getComponent(TeaserImage) 
call_user_func_array(Array,Array) 
Object.php:749
Object->__call(TeaserImage,Array) 
ViewableData.php:361
ProjectPage->TeaserImage() 
ViewableData.php:361
ViewableData->obj(TeaserImage,,1,,) 
SSViewer.php:91
SSViewer_Scope->getObj(TeaserImage,,1,,) 
SSViewer.php:504
SSViewer_DataPresenter->getObj(TeaserImage,,1,,) 
SSViewer.php:111
SSViewer_Scope->obj(TeaserImage,,1) 
.cache.themes.hermanndettmann2014.templates.Layout.Start.ss:68
include(/tmp/silverstripe-cache-php5.5.26-nmm1-www-htdocs-w00c0dec-new.hermanndettmann.com/w00c0dec/.cache.themes.hermanndettmann2014.templates.Layout.Start.ss) 
SSViewer.php:1031
SSViewer->includeGeneratedTemplate(/tmp/silverstripe-cache-php5.5.26-nmm1-www-htdocs-w00c0dec-new.hermanndettmann.com/w00c0dec/.cache.themes.hermanndettmann2014.templates.Layout.Start.ss,Start_Controller,,Array,) 
SSViewer.php:1098
SSViewer->process(Start_Controller,) 
SSViewer.php:1094
SSViewer->process(Start_Controller) 
Controller.php:203
Controller->handleAction(SS_HTTPRequest,index) 
RequestHandler.php:200
RequestHandler->handleRequest(SS_HTTPRequest,DataModel) 
Controller.php:153
Controller->handleRequest(SS_HTTPRequest,DataModel) 
ContentController.php:198
ContentController->handleRequest(SS_HTTPRequest,DataModel) 
ModelAsController.php:78
ModelAsController->handleRequest(SS_HTTPRequest,DataModel) 
RootURLController.php:130
RootURLController->handleRequest(SS_HTTPRequest,DataModel) 
Director.php:370
Director::handleRequest(SS_HTTPRequest,Session,DataModel) 
Director.php:153
Director::direct(/,DataModel) 
main.php:177

I already tried to run /dev/build/?flush=1 or /dev/build/?flush=all without
any success.

Hope some of you can help as I am pretty desperate about this problem
and found nothing on google search or in the forum.

Avatar
HermannDettmann

Community Member, 3 Posts

9 September 2015 at 5:37am

For some more insight: This is what I get if I run dev/build?flush=1 on the live machine:

Building database d01e2dfa using MySQL 5.5.43-nmm1-log

Creating database tables
File
Folder
Image
Image_Cached
Group
LoginAttempt
Member
MemberPassword
Permission
PermissionRole
PermissionRoleCode
RedirectedURL
SiteConfig
SiteTree
Page
ProjectPage
Table ProjectPage: created
Field ProjectPage.ID: created as int(11) not null auto_increment
Field ProjectPage.ProjectURL: created as mediumtext character set utf8 collate utf8_general_ci
Field ProjectPage.Roles: created as mediumtext character set utf8 collate utf8_general_ci
Field ProjectPage.Tech: created as mediumtext character set utf8 collate utf8_general_ci
Field ProjectPage.Client: created as mediumtext character set utf8 collate utf8_general_ci
Field ProjectPage.TeaserImageID: created as int(11) not null default 0
Index ProjectPage.TeaserImageID: created as ("TeaserImageID")
Table ProjectPage_Live: created
Field ProjectPage_Live.ID: created as int(11) not null auto_increment
Field ProjectPage_Live.ProjectURL: created as mediumtext character set utf8 collate utf8_general_ci
Field ProjectPage_Live.Roles: created as mediumtext character set utf8 collate utf8_general_ci
Field ProjectPage_Live.Tech: created as mediumtext character set utf8 collate utf8_general_ci
Field ProjectPage_Live.Client: created as mediumtext character set utf8 collate utf8_general_ci
Field ProjectPage_Live.TeaserImageID: created as int(11) not null default 0
Index ProjectPage_Live.TeaserImageID: created as ("TeaserImageID")
Table ProjectPage_versions: created
Field ProjectPage_versions.ID: created as int(11) not null auto_increment
Field ProjectPage_versions.RecordID: created as int(11) not null default 0
Field ProjectPage_versions.Version: created as int(11) not null default 0
Field ProjectPage_versions.ProjectURL: created as mediumtext character set utf8 collate utf8_general_ci
Field ProjectPage_versions.Roles: created as mediumtext character set utf8 collate utf8_general_ci
Field ProjectPage_versions.Tech: created as mediumtext character set utf8 collate utf8_general_ci
Field ProjectPage_versions.Client: created as mediumtext character set utf8 collate utf8_general_ci
Field ProjectPage_versions.TeaserImageID: created as int(11) not null default 0
Index ProjectPage_versions.RecordID_Version: created as unique ("RecordID","Version")
Index ProjectPage_versions.RecordID: created as ("RecordID")
Index ProjectPage_versions.Version: created as ("Version")
Index ProjectPage_versions.TeaserImageID: created as ("TeaserImageID")
SimplePage
Start
ErrorPage
RedirectorPage
VirtualPage
[Warning] require_once(PHP/CodeCoverage.php): failed to open stream: No such file or directory
GET /dev/build?flush=1&flushtoken=7285ff8079a02bb8f212ea43e22c3c0f
Line 18 in /www/htdocs/w00c0dec/new.hermanndettmann.com/framework/dev/phpunit/PhpUnitWrapper_3_5.php
Source
9 public function getVersion() {
10 return 'PhpUnit V3.5';
11 }
12
13 /**
14 * Initialise the wrapper class.
15 */
16 public function init() {
17 if(!class_exists('PHPUnit_Framework_TestCase')) {
18 require_once 'PHP/CodeCoverage.php';
19 require_once 'PHP/CodeCoverage/Report/HTML.php';
20 require_once 'PHPUnit/Autoload.php';
21 require_once 'PHP/CodeCoverage/Filter.php';
22 }
23 }
24
Trace
PhpUnitWrapper_3_5::init
PhpUnitWrapper_3_5.php:18
PhpUnitWrapper_3_5->init()
PhpUnitWrapper.php:157
PhpUnitWrapper::inst()
PhpUnitWrapper.php:169
PhpUnitWrapper::has_php_unit()
PhpUnitWrapper.php:261
require_once(/www/htdocs/w00c0dec/new.hermanndettmann.com/framework/dev/phpunit/PhpUnitWrapper.php)
ClassLoader.php:77
SS_ClassLoader->loadClass(PHPUnit_Framework_TestCase)
spl_autoload_call(PHPUnit_Framework_TestCase)
SapphireTest.php:12
require_once(/www/htdocs/w00c0dec/new.hermanndettmann.com/framework/dev/SapphireTest.php)
ClassLoader.php:77
SS_ClassLoader->loadClass(SapphireTest)
spl_autoload_call(SapphireTest)
FunctionalTest.php:25
require_once(/www/htdocs/w00c0dec/new.hermanndettmann.com/framework/dev/FunctionalTest.php)
ClassLoader.php:77
SS_ClassLoader->loadClass(FunctionalTest)
spl_autoload_call(FunctionalTest)
LeftAndMainTest.php:7
require_once(/www/htdocs/w00c0dec/new.hermanndettmann.com/framework/admin/tests/LeftAndMainTest.php)
ClassLoader.php:77
SS_ClassLoader->loadClass(LeftAndMainTest_Object)
spl_autoload_call(LeftAndMainTest_Object)
class_exists(LeftAndMainTest_Object)
DatabaseAdmin.php:204
DatabaseAdmin->doBuild(,1)
DatabaseAdmin.php:100
DatabaseAdmin->build()
DatabaseAdmin.php:80
DatabaseAdmin->index(SS_HTTPRequest)
RequestHandler.php:288
RequestHandler->handleAction(SS_HTTPRequest,index)
Controller.php:194
Controller->handleAction(SS_HTTPRequest,index)
RequestHandler.php:200
RequestHandler->handleRequest(SS_HTTPRequest,DataModel)
Controller.php:153
Controller->handleRequest(SS_HTTPRequest,DataModel)
DevBuildController.php:25
DevBuildController->build(SS_HTTPRequest)
RequestHandler.php:288
RequestHandler->handleAction(SS_HTTPRequest,build)
Controller.php:194
Controller->handleAction(SS_HTTPRequest,build)
RequestHandler.php:200
RequestHandler->handleRequest(SS_HTTPRequest,DataModel)
Controller.php:153
Controller->handleRequest(SS_HTTPRequest,DataModel)
RequestHandler.php:222
RequestHandler->handleRequest(SS_HTTPRequest,DataModel)
Controller.php:153
Controller->handleRequest(SS_HTTPRequest,DataModel)
Director.php:370
Director::handleRequest(SS_HTTPRequest,Session,DataModel)
Director.php:153
Director::direct(/dev/build,DataModel)
main.php:177

Hope this give someone a hint that I'm not able to see.

Avatar
helenclarko

Community Member, 166 Posts

9 September 2015 at 12:11pm

Hi HermannDettmann,

I'm not sure if both of these issues are related, but I would assume so.
The first post is is failing on a database query and the second post is failing to build your database.

The second posts gives more information, an issue with a requirement.

Looks like the file "PHP/CodeCoverage.php" doesnt exist.
Do you have a "PHP" folder?

Looks like PHPUnit may be a requiremnet which you are missing.

-helenclarko

Avatar
HermannDettmann

Community Member, 3 Posts

13 September 2015 at 9:23pm

Hey helenclarko,

thanks for your reply and please excuse being a bit late responding to it.

Yes these two issues relate to each other. The main problem is that I cant rebuild the
database with new added fields, because /dev/build fails. So, I don't know exactly where
to search for the PHP folder. I never established one. But if this is the problem, why this
issue doesn't appear on my local installation of silverstripe? Maybe its a problem with the
live server or the hosting provider?