miketayc / apprentice.dev Goto Github PK
View Code? Open in Web Editor NEWMVC Framework
MVC Framework
As we discussed, there are many ways to do this. If you think it will take too much rework to remove the standard class usages, then at least wrap each access with a ternary operator check. For instance,
echo $lesson->name
echo (!empty($lesson->name)) ? $lesson->name : ''
If you instead refactor to pass back PDO::FETCH_ASSOC
and wrap data in your Core_Model_Object
, then your checks are already performed in that class:
if ($lesson instanceof Core_Model_Object) {
// Won't throw errors even if 'anything' key doesn't exist in $lesson->_data
echo $lesson->getAnything();
}
Change the git username on my laptop. It looks like I made a shit-ton of commits to this repo.
As discussed, methods that don't have to do with any specific model should get moved into a Core_Model_Abstract
class, which extends Core_Model_Object
. For example,
App_Model_User::getCount()
Core_Model_Abstract::getCount()
Similarly, methods that have nothing to do with user but only other tables, should be moved into their own model class. For example,
App_Model_User::getAllTagsFromTagTable()
App_Model_Tag::getAll()
App_Model_User::getAllLessonNames()
App_Model_Lesson::getAllNames()
These come way after the other issues in terms of priority.
incubate
module. Really, you could have user module, lesson module, etc. Not the end of the world, but it would make more sense to have helpers, models, etc., specific to each module.$model->load($id)
, $model->save()
, which either updates or inserts depending on id
existing on model instance. Then creating a lesson looks like this:$lesson = Bootstrap::getModel('incubate/lesson');
foreach(array('name', 'date_due', 'description') as $field) {
$lesson->setData($field, $_POST[$field]);
}
$lesson->save();
and updating looks like
$lesson = Bootstrap::getModel('incubate/lesson')->load($_POST['id']);
$lesson->setName($_POST['name'])->save();
Of course, in doing this, you'd make use of the abstract save method, but you'd also need to do some validation to make sure that you don't save blank lessons. Probably a protected array of $_requiredFields
that must exist on _data
before the object is saved via parent method.
$userCollection = Bootstrap::getHelper('incubate/user')->getAllUsers();
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.