Anti-Moronic Posted June 21, 2009 Share Posted June 21, 2009 I have no idea how to approach this. Let's say I have a class with a function: <?php class someclass{ function do(){ mysql_query("fdafdsa dfafdsak fdsajlfdsa"); } } $someclass= new someclass; ?> Now, that may be updated, but I want to create a plugin that can be 'plugged in' to this class and function. Basically, I may need to amend a newly created field within the database or delete something straight after that query - how do I do this. Currently I call the function like so: <?php $someclass->do(); ?> Is there any way to change that function from within an extended class? Any help is greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/163172-i-am-so-baffled-right-now-creating-a-plugin-for-script/ Share on other sites More sharing options...
.josh Posted June 21, 2009 Share Posted June 21, 2009 if you have a method in a class that is extending another class, that is named the same as a method in the parent class, that method in the extending class will over-write the one in the parent class. Link to comment https://forums.phpfreaks.com/topic/163172-i-am-so-baffled-right-now-creating-a-plugin-for-script/#findComment-860909 Share on other sites More sharing options...
Anti-Moronic Posted June 21, 2009 Author Share Posted June 21, 2009 Do you have any advice on how I would amend database queries? What do you do? Basically, in the function do, I run a query, but then I want to be able to change this query, which means storing the query in a string. But where do I store these queries so I can access them in class which extends the parent class of those query definitions? Thanks for you help. Link to comment https://forums.phpfreaks.com/topic/163172-i-am-so-baffled-right-now-creating-a-plugin-for-script/#findComment-860913 Share on other sites More sharing options...
.josh Posted June 22, 2009 Share Posted June 22, 2009 maybe i'm not understanding your intentions here, but why don't you just pass the query string as an argument to the function? I mean, what exactly does this function actually do with the query string? Link to comment https://forums.phpfreaks.com/topic/163172-i-am-so-baffled-right-now-creating-a-plugin-for-script/#findComment-860938 Share on other sites More sharing options...
Anti-Moronic Posted June 22, 2009 Author Share Posted June 22, 2009 I'm trying to develop my script so that I can easily add plugins later. Thing is, I'm stuck at the part where I have to design the classes so I can extend and easily add/edit/delete functions within them. What I have is: <?php class override extends someclass{ function do(){ mysql_query("query"); // maybe do something else } } $someclass = new override; ?> So what I'm doing is overriding the old do() with my new do() and still maintaining all functions within the class::someclass - because I can't change the actual code that refers to $someclass->do(); ..I don't know, is there a better way? How do people create plugins for wordpress, I've searched but I just can't get any answers *showing core php*, same with any popular platform. It's always examples on the platforms native functions. Really, I am totally baffled.. Link to comment https://forums.phpfreaks.com/topic/163172-i-am-so-baffled-right-now-creating-a-plugin-for-script/#findComment-860954 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.