# plug **Repository Path**: akirakazu/plug ## Basic Information - **Project Name**: plug - **Description**: another php orm - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2015-01-03 - **Last Updated**: 2020-12-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README plug ======== painless data access * Bean: a row in a table * Model: a table in a database * Controller: business logics Bean ==== * Bean.getId * Bean.setId * Bean.get * Bean.set * Bean.import * import according to Model's schema * Bean.export * convert key naming style according to Model's schema * localazation made possible * invoke onExport function, allow customization before really exporting data * Bean.save * Bean.trash * Bean.clear * Bean.setIfEmpty * Bean.rm * Bean.getAssociations Model ==== * Model.table\_name * declare the table for this Model * Model.schemas * as, type, min_length, max_length, required, unique * Model.main\_key * Model.main\_key\_as * Model.dispense * create a new bean of this Model * Model.save * save a bean to database, will invoke onUpdate function before * will invoke onCreate function if this is an INSERT method afterwards * should be used with try catch, to capture invalid arguments * Model.trash * DELETE a bean from database, will invoke onTrash function * Model.find * find beans by an array of conditions, ORDER BY, and LIMIT * will return an empty array if nothing found * Model.findOne * similar to Model.find, but only return the first bean found. Will return null if nothing found * Model.findWithSQL * allow raw SQL query * Model.onCreate * invoked after INSERT operation, is supposed to do some association works * should throw exception if the operation is not allowed * Model.onUpdate * invoked before INSERT and UPDATE operation, is supposed to do full validation beyond schemas, fill in default values * should throw expeption if the operation is not allowed * Model.onTrash * invoked before DELETE operation, is supposed to do some check and cleanup works * should throw expeption if the operation is not allowed * Model.onExport * invoked right before bean.export returns, is supposed to finalize output data * private Model.validate * validate bean against to schemas * private Model.validateValue * private Model.query * execute SQL queries * private Model.preparevalueForSQL * do type convention, SQL-save string escape, etc. * private Model.buildCreateSQL * private Model.buildRemoveSQL * private Model.buildUpdateSQL * private Model.buildFindSQL