Code: Select all
includes/constants.php
Code: Select all
define('MY_CUSTOM_TABLE', $table_prefix . 'my_custom_table');
I have to pass a specific class to the controller constructor?
Thanks in advance
Code: Select all
includes/constants.php
Code: Select all
define('MY_CUSTOM_TABLE', $table_prefix . 'my_custom_table');
Thanks for the helpnicofuma wrote:to get the $table_prefix value and any other service you need to use the dependency injection (for the table_prefix it's %core.table_prefix%)
If what you're asking is how do you reference your own custom db tables in your extension, add them to the services.yml (or a separate tables.yml that you import into services.yml) and then use them as any other service.RiccardoB. wrote:When I developed a MOD for 3.0.x I added custom tables towith a code likeCode: Select all
includes/constants.php
In a new 3.1.x Extension, trying to follow the "keep more inside the extension", I won't edit constants but how could I get the $table_prefix value so I can use it in queries in my controller?Code: Select all
define('MY_CUSTOM_TABLE', $table_prefix . 'my_custom_table');
I have to pass a specific class to the controller constructor?
Thanks in advance
Code: Select all
parameters:
tables.my_custom_table: %core.table_prefix%my_custom_table
my.some.service:
class: my\extension\myclass
arguments:
- @dbal.conn
- % tables.my_custom_table%
Code: Select all
class myclass
{
public function __construct(\phpbb\db\driver\driver_interface $db, $my_custom_table)
I thought I need to get $table_prefix inside the container... but yes, this is what I'm looking for, thanks!VSE wrote:If what you're asking is how do you reference your own custom db tables in your extension, add them to the services.yml (or a separate tables.yml that you import into services.yml) and then use them as any other service.