ORM Entities not created
Permalink
Hi
I'm currently trying to create a v8 package. But I stuck on creating the tables. On install, the table is not created.
controller.php
the entity in steff_testing/src/SteffTesting/Testing/Testing.php starts like this
Any idea why the database table is not beeing created?
Thanks a lot.
Steff
I'm currently trying to create a v8 package. But I stuck on creating the tables. On install, the table is not created.
controller.php
<?php namespace Concrete\Package\SteffTesting; use \Concrete\Core\Backup\ContentImporter; class Controller extends \Concrete\Core\Package\Package{ protected $pkgHandle = 'steff_testing'; protected $appVersionRequired = '8.5.2'; protected $pkgVersion = '0.0.28'; protected $pkgAutoloaderMapCoreExtensions = false; protected $pkgAutoloaderRegistries = [ 'src/SteffTesting' => 'SteffTesting' ]; protected $pkgDescription = 'Testing Package'; protected $pkgName = 'Testing'; public function install() { $pkg = parent::install();
Viewing 15 lines of 22 lines. View entire code block.
the entity in steff_testing/src/SteffTesting/Testing/Testing.php starts like this
<?php namespace SteffTesting\Testing; use Doctrine\ORM\Mapping as ORM; /*** * @ORM\Entity * @ORM\Table(name="Testing") */ class Testiing{ /*** * @ORM\Id * @ORM\Column(type="integer") */ protected $tID; public function getTID() { return $this->tID; } public function setTID($tID){ $this->tID= $tID; }
Viewing 15 lines of 21 lines. View entire code block.
Any idea why the database table is not beeing created?
Thanks a lot.
Steff
Tank you linuxoid
This helped me a lot. Where do i have to place the refresh? there are multiple install functions.
Thank you
Kind regards,
Steff
This helped me a lot. Where do i have to place the refresh? there are multiple install functions.
Thank you
Kind regards,
Steff
I usually refresh the entities in my src/Package_Name/Install/Installer.php in both install() and upgrade() functions. You may as well put it in the package controller's install and upgrade.
Thank you linuxoid
I always get
I think i have to declare a use .... but couldn't figure it out. Could you please help me again?
Thanks a lot.
I always get
Class DatabaseORM not found
I think i have to declare a use .... but couldn't figure it out. Could you please help me again?
Thanks a lot.
use Concrete\Core\Support\Facade\DatabaseORM;
Ref.
https://github.com/concrete5/concrete5/blob/develop/concrete/config/...
Another excellent ref.
https://github.com/shahroq/whale_c5_cheat_sheet...
thanky linuxoid. This helped me a lot
https://www.concrete5.org/marketplace/addons/free-simple-comments/...
especially in the package controller, directory structure, namespaces and entity classes... and spelling, e.g.
- I assume 'Testiing' should have been 'Testing'
- The class namespace has to be SteffTesting, not SteffTesting\Testing (when you correct the class name spelling it should throw an error)
- your column 'id' has to match the variable name '$id', not '$tid'
- and don't forget to refresh the entities after installation