Hi Everybody
i'm wondering whats the best way, whenn i want to ad a function to the admin/includes/function.php
i need to add there a function, should i put it there (but thenn on a update it's deleted) should i make a special new database2.php or use override? thank you to help me start coding the right "phoenix-way"
code design
-
loop
- Contributor
- Posts: 253
- Joined: Thu Mar 25, 2021 12:26 pm
- Phoenix Version:
- Has thanked: 7 times
- Been thanked: 3 times
Re: code design
if i have a database function i cannot put it in a class file...or do i missunderstand you? i can make like "database2.php" in the /functions folder and in application top i make a include, or you would suggest a other way? (because thenn it's the application top which i changed directly....)
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: code design
Code: Select all
class my_db_functions {
public static function do_something() {
}
}
Code: Select all
my_db_functions::do_something();This is somewhat hard to discuss conceptually, as the approach that one takes depends on the exact circumstances.
-
loop
- Contributor
- Posts: 253
- Joined: Thu Mar 25, 2021 12:26 pm
- Phoenix Version:
- Has thanked: 7 times
- Been thanked: 3 times
Re: code design
hm okay,..the point is i have a database function which i used very often in my old oscommerce shop and i don't want to rewrite everythin, so it need to be a function (and not your class idea) so at the moment i have to make a new file and a manual include in application top and in 1.0.8.1 i can make then a nice hook insert. looks like this is the only solution
-
raiwa
- Certified Developer
- Posts: 1640
- Joined: Sat Dec 21, 2019 8:08 am
- Phoenix Version: 1.1.0.6
- : Buy Me A Beverage
- Has thanked: 70 times
- Been thanked: 152 times
Re: code design
you can use a system hook and put your function outside the class. The system hook will be outo loaded early in application top, so your function will be available without the need to use a include and modify application top.
Or you can use a function file and load it via db system hook.
Or you can use a function file and load it via db system hook.
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing
Need Help?viewtopic.php?f=10&t=27
https://docs.google.com/spreadsheets/d/ ... sp=sharing
Need Help?viewtopic.php?f=10&t=27