Community Page
- www.phpfour.com/blog Jump to website »
-
Subscribe -
Community
-
Top Commenters
-
Popular Threads
-
Recent Comments
- Thanks for the sharing.
- Twe2 as it is now is no more!
- Hello Austin, good to know the base class helped you. And thanks for sharing the snippet for allowing multiple items :)
- Sorry, you have to redirect to Paypal's website for payment - it is mandatory.
- Thanks
Md Emran Hasan (phpfour)
This is Emran Hasan's blog for PHP, CSS, XHTML, JavaScript, Web 2.0, AJAX, Usability, and Web Standards related views, ideas, and sharing.
I developed this extension of CodeIgniter’s Model last year, but never had the chance to publish it. The main purpose of this extension is to make a dev’s life easy. This extension has been used by several of my devs at RBS and has been proved to increase productiv
... Continue reading »
11 months ago
You've saved CodeIgniter developers valuable time. :D
11 months ago
On this particular case your source code (mainly its method names and implementation) look strangely familiar to CakePHP's model implementation (for outsiders, concentrate on the method names and signatures):
https://trac.cakephp.org/browser/branches/1.2.x...
To give a small preview of the similarities:
* $this->data and $this->useDbConfig used on both
* getAffectedRows()
* getNumRows()
* getInsertID()
* getID()
* lastQuery()
* query()
* remove()
Well, almost all methods are borrowed from CakePHP implementation.
So I think you seriously need to revisit your use of open source software and inability to respect its MIT license.
11 months ago
11 months ago
You should never hack the core - it makes upgrading a pain.
Thanks for the great library - I posted a link to this from my blog as well as some of my own comments concerning it! A great contribution to the community.
11 months ago
Thanks for the appreciation. I actually tried not to hack into the core but the overloading of base CI classes didn't work with the Model class.
If you can get it working in any way, I'd be more than happy to follow that and update the install steps accordingly.
Thanks a lot.
11 months ago
Thank you very much for reminding me the source. It is my bad that I completely forgot to mention the credit to CakePHP's model implementation.
I actually created this in the middle of last year and have been using from then. The day I posted it here, I was actually rushing - so the due credit was missing. I'm going to update the post with a mention to this.
And btw, I've only taken inspiration for the methods and variable names. The code utilizes the Active Record library of CodeIgniter. Also, it doesn't burden the developer with the associations.
Thanks a lot.
11 months ago
11 months ago
@mariano - Damn dude. Relax. He did thank CakePHP for their inspiration. NO need to be so anal.
11 months ago
11 months ago
Great work, Thats what I am saying since you've showed me the code last year sometime. But unfortunately I have left using CI.
@Mariano
Thanks for pointing out that method names were borrowed from CakePHP, but that clearly didnt disrespect MIT license model. It is not a derived work but written from scratch, did you note that? I appreciate your observation but I still think you were a bit rough at this one. Anyway, thanks. No hard feelings.
11 months ago
Open PHPFour's 'Model.php' and do the following to it:
Change:
class Model {
To:
class CI_Model {
Change:
function Model()
To:
function CI_Model()
Save the file as 'Model.php' and place it in:
application/libraries
This is the proper way to replace core libraries. Source:
http://codeigniter.com/user_guide/general/core_...
11 months ago
Leaving out the CI_ and putting it in application/libraries allows it to run perfectly fine.
I wonder why CodeIgniter doesn't allow the CI_ override for the Model?
11 months ago
Go away you miserable creature. Take your nastiness to a cake forum.
11 months ago
For the sake of CI, I hope you have more of the "other kind" of people. You know, people that KNOW something about something, and HELP the project back, for a change.
11 months ago
What Mariano did was just to remind me something that I forgot, although in a bit rough way, but he had no bad intention in mind and I thanked him for that.
We're all community enthusiastic, let's not create divisions and point fingers.
10 months ago
You really want him to re-name "query(), "getNumRows()", "$this->data" and other method/property names? These are standard method names used by pretty much every database abstraction layer in the history of programming.
Saying phpfour isn't respecting the MIT license is a bit harsh. He's just looking at other libraries for inspiration and building his own. Nothing wrong with that.
10 months ago
6 months ago
Do bear in mind that you're a guest on this website, not an unpaid asshole.
Your message is true, but your delivery is definitely flawed. I'd recommend trying to be a little more polite, or you'll keep getting comments from people like Ryan. While I agree with what you said, the way you came across was pretty overwhelmingly full of douchebaggery. I have not personally visited the CakePHP forums but if they're full of people such as yourself who display a genuine "inability" to be polite, I don't plan on visiting anytime soon.
It is rather apparent that you're a CakePHP fan, but don't turn it into some form of irrational zeal. Step one would be to resist all caps. Step two would be to assume that other people aren't as brilliant as you, and don't have the MIT license memorised. Step three would be to perhaps quietly suggest that the author credit the source that shows definite similarity to his code snippets, instead of full-force attacking him.
Thanks for the info, Emran. I was trying to extend Model.php, and I eventually just popped a customised copy of "Model.php" in my APPPATH/libraries folder and overrode the default Model file altogether.
10 months ago
8 months ago
Fatal error: Call to undefined method CI_DB_mysql_driver::field_names() in C:\home\codeigniter\system\application\libraries\MY_Model.php on line 196
and I just can't work out how to get around it... any help would be great!
8 months ago
8 months ago
What I've done (in addition to the fix below) is rename it to MY_Model.php, placed it in system/application/libraries, updated the constructor to class MY_Model extends Model, and that's literally it. It's all working so far - I'll post back if I hit another snag :)
It may well be something they've fixed in these latest updates to CI, so you may wish to try it again, and if it works for, update your instructions accordingly.
Thanks for your contribution - it looks like it will be very useful!
8 months ago
Replace Line 196 of MY_Model.php:
$this->fields = $this->db->field_names($table);
with
$this->fields = $this->db->list_fields($table);
as field_names() is deprecated, and clearly in 1.7.0 does not work!!
Hope this helps someone else :)
8 months ago
Everybody, please follow Jacob's two comments if you're using CodeIgniter 1.7.0.
Cheers!
5 months ago
This could be because I'm using Matchbox 0.9.4 which hasn't been updated to include a lot of the new code in Loader.php yet...
But apart from that, this is such a time saver and a brilliant piece of kit to add to your Code Igniter arsenal.
Thanks heaps for creating it and looking forward to seeing the additional features you've got planned.
5 months ago
Saves even more time ^^
5 months ago
Thanks for the innovative work Emran. The comments also proved extremely helpful.
@Michael Wales: Extremely helpful and encouraging as always (esp. in the CI forums).
@Jacob & @stensi: Thanks for the additions.
@ryan & @joshdavey & @abe: Good call all around. To come on someone's forum and sound so arrogant shows a lack of taste, respect and manners.
4 months ago
Iam a newbie to CI.Thanks again.
Abbas
4 months ago
your extension save me lot of time! :)