Hi, everyone! I would like to share another helper instrument for extension developers. It is class, called "Model"[1].
Abstractions help us keep code clean and readable, focus on logic. One way or another, when developing big mediawiki extension, which should have a lot of functions and work with database, we should create models for not to be messed in SQL at the end of development. I have created small abstract class Model, which can help to solve this task easily. Possibly it have some minuses, but feel free to make it better, if you involved. To describe short how Model works, look at this example: fetch user by id, change password and save user back. *With Mediawiki: --------------- //Select $dbr = wfGetDB( DB_MASTER ); $result = $dbr->select( 'users', '*', array( 'user_id' => 10 ), __METHOD__ ); $user = $result->fetchObject(); } $newPassword = '1234'; //Update $dbr->update( 'users', array( 'password' => $newPassword ), array( 'user_id' => 10 ), __METHOD__ ); *With Model over Mediawiki: -------------------------- $users = Model_User::find( 10 ); $users[0]->password = '1234'; $users[0]->save(); Today, Model know how to load models from DB (inc. conditions), validate them from external data, store models back and delete entities from DB. Have load-on-access. You can find more examples and documentation by following this links: [1] https://github.com/vedmaka/Mediawiki-Model ------------------------------------------------------------------------------ Introducing Performance Central, a new site from SourceForge and AppDynamics. Performance Central is your source for news, insights, analysis and resources for efficient Application Performance Management. Visit us today! http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk _______________________________________________ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel