Jump to content

Concatenate in query


wegorz23

Recommended Posts

Posted

Hello, how can I use concatenate in query SELECT ? 

I have this query : $row = \IPS\Db::i()->select('*', 'cms_custom_database_' . \IPS\Settings::i()->site_ccd, array('member_id=?', \IPS\Member::loggedIn()->member_id));

But this doesnt work .

 

Edit: How can I access variables in a file conf_global.php ? Because \IPS\Settings::i()->site_ccd return null, so this doesnt work

Posted

Please take a look at the \IPS\Settings file:) You can't just use custom settings in the conf_global.php, you'll need to whitelist them via a hook

	public function getAllowedFields()
	{
		return array( 'sql_host', 'sql_database', 'sql_user', 'sql_pass', 'sql_port', 'sql_socket', 'sql_tbl_prefix', 'sql_utf8mb4', 'board_start', 'installed', 'base_url', 'guest_group', 'member_group', 'admin_group' );
	}

 

Posted
2 hours ago, wegorz23 said:

Ok :). So there is no other way to do it? 

Where located this file  \IPS\Settings ? 

Inside the system folder in the root of your forum folder.

Posted

Generally speaking, you shouldn't be adding settings to conf_global.php. You should add them via the developer center to a plugin or application (then you don't need to edit conf_global.php)

If that's not an option, you still need a plugin on \IPS\Settings to add your new setting to the getAllowedFields() method Daniel highlighted.

Posted

For your needs, you basically just need to create a plugin (step1) and create a setting in that plugin, including a settings.php file to allow that setting to be modified (step 4).

The rest that is in that guide is irrelevant to what you want to do.

Result: \IPS\Settings::i()->your_setting will become available.

Posted

Can't he just define a constant, and use that?

define( 'SITE_CCD', 123 );
$row = \IPS\Db::i()->select('*', 'cms_custom_database_' . SITE_CCD, array('member_id=?', \IPS\Member::loggedIn()->member_id));

 

EDIT: Or not use a setting at all. Why can't you hard-code the database ID, @wegorz23?

Posted

Yes, sorry - my comments were centered more around the idea of releasing what you are working on to others. If this is just for your own uses and you aren't super familiar with our framework, I wouldn't overcomplicate it too much.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...