Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
wegorz23 Posted July 17, 2018 Posted July 17, 2018 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
Daniel F Posted July 17, 2018 Posted July 17, 2018 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' ); }
wegorz23 Posted July 17, 2018 Author Posted July 17, 2018 Ok :). So there is no other way to do it? Where located this file \IPS\Settings ?
Faqole Posted July 17, 2018 Posted July 17, 2018 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.
bfarber Posted July 17, 2018 Posted July 17, 2018 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.
wegorz23 Posted July 19, 2018 Author Posted July 19, 2018 @bfarber I have no idea what you are talking about ?. How can I add them via the developer center to a plugin or application ? Could you explain how to do it?
Nathan Explosion Posted July 19, 2018 Posted July 19, 2018 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.
Martin A. Posted July 19, 2018 Posted July 19, 2018 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?
wegorz23 Posted July 19, 2018 Author Posted July 19, 2018 @Martin A. I make my life difficult :D. Thanks guys for help ! :)
bfarber Posted July 19, 2018 Posted July 19, 2018 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.