Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted July 17, 20186 yr 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
July 17, 20186 yr 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' ); }
July 17, 20186 yr Author Ok :). So there is no other way to do it? Where located this file \IPS\Settings ?
July 17, 20186 yr 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.
July 17, 20186 yr 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.
July 19, 20186 yr Author @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?
July 19, 20186 yr 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.
July 19, 20186 yr 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?
July 19, 20186 yr 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.