Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
No new table on database when creating a custom application
I try to create a new application and add new table into database with
+ Apache/2.2.11 (Win32) PHP/5.3.0
+ Server version: 5.1.36-community-log
+ Vanilla 2.0.3, 2.0.11
Steps:
1) Clone skeleton folder to new hello folder
2) In controllers/class.skeletoncontroller.php
+ change file name to class.hellocontroller.php
+ change class name to HelloController
+ add new method
3) In settings/about.php
+ change $ApplicationInfo['Skeleton'] to $ApplicationInfo['Hello']
+ delete this line: 'AllowEnable' => FALSE,
4) In settings/class.hooks.php
+ change class name to HelloHooks
5) In settings/structure.php
+ add below
When I enable this application in Dashboard, the table HelloWorld is not created in database.
But I can access to the application through localhost/vanilla/hello/ which prints out "Hello World!" message.
Did I do something wrong?
By the way,
In vanilla\settings\structure.php
But in skeleton\settings\structure.php
Why difference?
+ Apache/2.2.11 (Win32) PHP/5.3.0
+ Server version: 5.1.36-community-log
+ Vanilla 2.0.3, 2.0.11
Steps:
1) Clone skeleton folder to new hello folder
2) In controllers/class.skeletoncontroller.php
+ change file name to class.hellocontroller.php
+ change class name to HelloController
+ add new method
public function index() {
echo "Hello World!"; // look funny but it is the simplest for a test
}
3) In settings/about.php
+ change $ApplicationInfo['Skeleton'] to $ApplicationInfo['Hello']
+ delete this line: 'AllowEnable' => FALSE,
4) In settings/class.hooks.php
+ change class name to HelloHooks
5) In settings/structure.php
+ add below
$Construct = Gdn::Structure();
$Construct->Table('HelloWorld')
->PrimaryKey('MessageID')
->Column('Message', 'varchar(50)')
->Set($Explicit, $Drop);
When I enable this application in Dashboard, the table HelloWorld is not created in database.
But I can access to the application through localhost/vanilla/hello/ which prints out "Hello World!" message.
Did I do something wrong?
By the way,
In vanilla\settings\structure.php
$SQL = $Database->SQL();
$Construct = $Database->Structure();
But in skeleton\settings\structure.php
$Construct = Gdn::Structure();
Why difference?
Tagged:
0
Comments
I believe what you need is to include the structure.php file in the Setup method in the class.hooks.php file:
// Structure include(PATH_APPLICATIONS . DS . 'appname' . DS . 'settings' . DS . 'structure.php');
Structure.php will never get triggered if you don't call it in Setup.
That should definitely be in the skeleton.
It works for me. Actually, I clone Setup method from vanilla\settings\class.hooks.php and change appname to adjust my app.