rbrown Posted December 20, 2013 Share Posted December 20, 2013 I have found a few online but after using them, either they have some issues (more than I want to fix) or tons of extra stuff in there like filtering which I like to do before I call the db, or they have both procedure and OO in the same class and most have no docblocks. So if I want to do something else I have to go back to the class and look for what I want. I don't want to reinvent the wheel if I don't have to, and write my own. So does anyone know where there is a good oop only mysqli class with docblocks out there? Thanks, Bob Quote Link to comment https://forums.phpfreaks.com/topic/284880-looking-for-a-good-oop-mysqli-class-with-docblocks/ Share on other sites More sharing options...
mac_gyver Posted December 20, 2013 Share Posted December 20, 2013 since php has a build-in mysqli OOP class, what exactly do you need that the built-in class doesn't do directly or that you cannot extend it to do? you haven't exactly stated any specific functional needs. Quote Link to comment https://forums.phpfreaks.com/topic/284880-looking-for-a-good-oop-mysqli-class-with-docblocks/#findComment-1462868 Share on other sites More sharing options...
rbrown Posted December 20, 2013 Author Share Posted December 20, 2013 Instead of typing: new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } Just use: $whatever = new DB(); Or Be able to handle array updates instead of typing it all out each time: $update = array( 'name' => 'Not spanky', 'email' => 'spanky@email.com' ); $update_where = array( 'user_id' => 44, 'name' => 'spanky' ); $whatever->update( 'UsersTable', $update, $update_where, 1 ); And have all the other commands shortcut like this. Basically I'm looking for a class so I don't have to keep writing the same code over and over again. connection, insert, update, etc... handle array inputs, error handling, multiple database connections, freeing memory, closing the connection, etc... Quote Link to comment https://forums.phpfreaks.com/topic/284880-looking-for-a-good-oop-mysqli-class-with-docblocks/#findComment-1462869 Share on other sites More sharing options...
jazzman1 Posted December 20, 2013 Share Posted December 20, 2013 It sounds like you're looking around something like object relational mapping (ORM) libraries in PHP. Google -"Doctrine Project". Quote Link to comment https://forums.phpfreaks.com/topic/284880-looking-for-a-good-oop-mysqli-class-with-docblocks/#findComment-1462874 Share on other sites More sharing options...
rbrown Posted December 21, 2013 Author Share Posted December 21, 2013 Interesting... Didn't know about it. From what little reading I did so far, maybe a little overkill for what I need... Might have some use... have to do some more reading... Plus I already wrote a Composer type program for my programs. Went through and wrote a program over a year ago that finds whatever the programs needs to run based on the license key or whatever function is being called and installs it regardless of whatever the end-user has named the dir structure. And does it on the first time called. And then only after that, if you change the dir structure or call another function, class, module, css, jquery, javascript, etc... not found. (Kind of a anti hacker feature, like with an exploit for Wordpress 99% percent of the sites out there have the same dir structure. Being able to rename everything makes it harder for the hacker to figure out if it running the software first, and then having to try to and figure out what they named the dirs.) And it has a ton of other functions like emailing the admin on change so if someone got in and changed the code, it would tell you. And if it can't connect to the checking / upload server or if the checking / upload server hasn't heard from the server it will notify you. Has automatic anti-scraper functions, caching, full automatic seo and tag cloud and automatic 404 pages that will return information from the site and data from the internet based on whatever they tried to get at. Plus you can run the software as any extension: ,asp, cfm, html, php, jsp etc... regardless of the type of server it is sitting on without using any apache rewrite codes. I'll probably end up just writing what I want. Was hoping I could save some time... Testing and making it hacker / idiot proof takes a long time... Thanks, Bob Quote Link to comment https://forums.phpfreaks.com/topic/284880-looking-for-a-good-oop-mysqli-class-with-docblocks/#findComment-1462875 Share on other sites More sharing options...
ignace Posted December 21, 2013 Share Posted December 21, 2013 Doctrine comes in 3 packages. You only need the DBAL package. Since you already use Composer, installing doctrine is easy: $ php composer.phar require doctrine/dbalSetting up is as easy as: http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html Quote Link to comment https://forums.phpfreaks.com/topic/284880-looking-for-a-good-oop-mysqli-class-with-docblocks/#findComment-1462882 Share on other sites More sharing options...
rbrown Posted December 21, 2013 Author Share Posted December 21, 2013 I'm not using Composer, I wrote my own Composer type program. I started writing my own mysqli wrapper. Then I can add other stuff if I want too. the closest one I found to what I'm looking for is on github: bennettstone/simple-mysqli There are some programming errors in the class. But it gave me a few ideas on how I'm going to do mine. Quote Link to comment https://forums.phpfreaks.com/topic/284880-looking-for-a-good-oop-mysqli-class-with-docblocks/#findComment-1462884 Share on other sites More sharing options...
ignace Posted December 21, 2013 Share Posted December 21, 2013 A typical case of Not Invented Here Syndrome Quote Link to comment https://forums.phpfreaks.com/topic/284880-looking-for-a-good-oop-mysqli-class-with-docblocks/#findComment-1462891 Share on other sites More sharing options...
rbrown Posted December 21, 2013 Author Share Posted December 21, 2013 No it's a case of not wanting to add more crap than is needed to do the job. Quote Link to comment https://forums.phpfreaks.com/topic/284880-looking-for-a-good-oop-mysqli-class-with-docblocks/#findComment-1462893 Share on other sites More sharing options...
ignace Posted December 22, 2013 Share Posted December 22, 2013 By adding more time writing/figuring it (out) yourself instead of using available libraries? That's what I am gonna say to my boss for the next project. Oh no, we don't use frameworks they add too much crap that we don't need. Instead I am gonna write my own and add another 3 months of programming and 6 months of debugging to the project. He's gonna LOVE it! Quote Link to comment https://forums.phpfreaks.com/topic/284880-looking-for-a-good-oop-mysqli-class-with-docblocks/#findComment-1462939 Share on other sites More sharing options...
rbrown Posted December 24, 2013 Author Share Posted December 24, 2013 Well if you were a better programmer, it wouldn't take you 3 months to write a mysqli wrapper and 6 months to debug it. Probably why you're not the "boss" and I am. FYI... it's already done and tested. Plus if you were a better programmer, you would know that there is a time to use framework and times not to use a framework. It depends on what the project is. Like when you build a house, would you use a framing hammer or a sledgehammer to drive nails? I'm guessing, you would choose the latter. The point is, use the required tools for the job. Don't over kill it or over think it. Then it won't take you 9 months to finish a simple one page project. And while I'm at it, why are there so many rude people on the this forum? That is the main reason why I have stayed away from here. I was hoping they had gotten weeded out. Guess not... so it will be another year or more before I come back. If answering questions without shoving your opinions down their throat and getting sarcastic if they don't agree with you, is is too much for you to handle, then don't answer any questions. Also have someone fix the link "Forum Guidelins" it's "Forum Guidelines" And while you are at it, go to that page and read the do's and don'ts. Pay attention to the first rules listed in both of those paragraphs. Quote Link to comment https://forums.phpfreaks.com/topic/284880-looking-for-a-good-oop-mysqli-class-with-docblocks/#findComment-1463058 Share on other sites More sharing options...
gizmola Posted December 24, 2013 Share Posted December 24, 2013 rbrown, You sure are combative in this thread, and take offense very easily. You asked a question, and when people attempted to answer it, your reaction was dismissive. If you're not open to the responses of others, then a forum like this is of no value to you. You seem to approach things with a lot of preconceptions, and when any of them are challenged you react with hostility. I think you would benefit from really asking yourself whether or not you are able to open your mind to new ideas that challenge some of your beliefs. Specifically, regardless of what you claim, you exhibit every aspect of NIHS. Even though you weren't even aware of Doctrine or any of the other orm's out there, you're ready to write them off as "more crap than is needed to do the job" when I'd warrant you don't understand how they were architected, or what specific design goals they have. As for the github library you found, apparently you don't understand github. If the library "has a few bugs" then a reasonable reaction to that would be, fork the repo, fix the few bugs, and then issue pull requests to patch them. In other words, to contribute, rather than leech and make the overall eco-system better, while at the same time, benefitting personally. In other words, where there could be a win-win, your reaction is instead to copy-paste-steal what you like without giving back to the community upon which you depend entirely. I have to question whether you understand open source whatsoever, or github specifically. And, yes, you can fork a repo, create your own branch, and use that branch in composer, in case you were wondering. The system allows you to get what you want, even if others don't agree with what you did, and choose to never accept your patches. Based on your description, I'm not sure what exactly your "composer" tool does, mainly because you refer cryptically to "license keys" and "installation" where those concepts aren't even applicable to php, but even if there is something interesting in what you created, it's largely irrelevant. Composer is the de facto standard dependency resolution and PSR-0 autoloader building tool for the php community. Component libraries have all been busy modifying themselves to be PSR-0 compatible so that they can be used with composer. You seem to be so unaware of what is going on with the php language specifically, and the ecosystem and thought leaders of the larger component library and framework community, that it's hard to take anything you say seriously whatsover. Composer has been out for about 2 years I think, and even before it, there was PEAR, so I don't find your argument for why you decided to roll something yourself very convincing, but I suppose we should all take your word for it, that it is a superior solution that does everything composer does, better, and that you already been there, done that, and for that reason have no need of compser, which just makes you look like a complete beginner. Your analogy about hammers,, simply illustrates that you don't understand software libraries very well. The library facilitates and becomes the end product. It is not a tool, it is the fabric of the software itself. You could make the argument that some libraries, may introduce memory bloat or inefficiencies to the end product, although often those arguments don't hold water in a traditional web applications, especially when the claimant never takes the time to profile the application and determine where measurable performance bottlenecks actually exist, instead preferring their theoretical pre-optimization arguments as an excuse to reinvent the wheel for no noticeable gain, and producing undocumented and unmaintanable libraries that are full of bugs. Since I know Ignace through his years of participation on this forum, and you clearly don't, it simply makes you look silly and unsophisticated when you start lecturing someone who, until you contribute something here or anywhere for that matter that proves otherwise, is in all probability a far better programmer than you are now or will ever be. I was involved with an argument along these lines some years back, about the use of a few libraries in the Zend Framework 1.0. "OMG The ZF is 80 megabytes in size!. That is SO big, there are SO MANY LIBRARIES. It's going to, I dunno weigh down the project with all that STUFF!" "Umm, I'm using one class from it, that allowed me to generate these 20 syndicated feeds and render them in rdf and atom formats, and I wrote everything, and got it working in 30 minutes. Just because we're not using the other classes, doesn't mean that we shouldn't use this one." "BUT IT'S 80 megabytes!" Well, no it's not. The size of the libraries in their totality took up 80 megabytes on the server, but were never included, thus completely irrelevant to the argument. So it seems to be that your argument is made on the same lines. "I must have a tool that does exactly what I want, this second, and not one thing more." That's patently ridiculous, and leads to the self fulfilling prophecy of failure of anything other than what you just wrote yourself, for any library to ever be good enough for you. And while I'm at it, why are there so many rude people on the this forum? That is the main reason why I have stayed away from here. I was hoping they had gotten weeded out. Guess not... so it will be another year or more before I come back. Your supposition is incorrect, and I simply won't accept that from you, because my sample size of posts here over 10 years and many tens of thousands of threads is just far greater than yours will ever be. There are not a lot of rude people on this forum. Like the rest of the world, there are some, but in large part, this is one of the last bastions of tolerance for newbie PHP developers, and has maintained that attitude of tolerance for the last decade. Go ask your question on one of the many other alternative forums, and see the reaction you receive to what many would interpret as a "can you do the googling and research for me to find me this thing I want because I'm too lazy to do it myself?" If you are attracting "rude people" and "rude responses" then perhaps the common denominator is occupying the chair in which you sit. If you find yourself enraged, because someone links you to NIHS, then you might want to try and figure out why you have such a thin skin. And for the record, no one here cares whether you ever come back and post to phpfreaks again. Quote Link to comment https://forums.phpfreaks.com/topic/284880-looking-for-a-good-oop-mysqli-class-with-docblocks/#findComment-1463066 Share on other sites More sharing options...
rbrown Posted December 25, 2013 Author Share Posted December 25, 2013 First, (he/she) didn't fully read my question, Second, I had poked around the internet. Third, I was hoping since you guys are supposed to be the "bastions of tolerance for newbie PHP developer" You could enlighten me on a good php wrapper so I wouldn't have to reinvent the wheel. Not tell me to use a framework... Then (he/she) started it with the "A typical case of Not Invented Here Syndrome " Which I thought was rude since I was looking for a mysqli wrapper and not wanting to use a full blown framework. Wait... I forgot this is: "one of the last bastions of tolerance for newbie PHP developers, and has maintained that attitude of tolerance for the last decade." And (he/she) came back with the "3 months to code 6 months to debug..." Without even asking what I was doing to begin with... But... what was I thinking... this is: "one of the last bastions of tolerance for newbie PHP developers, and has maintained that attitude of tolerance for the last decade." But it sounds like (according to you two...) if you need to anything, you must use a framework... Irregardless of what you are trying to accomplish... This article sums it up for me there are others, but they pretty much say the same thing... http://checkedexception.blogspot.com/2010/04/why-you-should-not-use-web-framework.html It depends on what you are doing... Then you pick the tools... And FYI I use a pull-based or component-based framework, (so I can return results from multiple controllers as needed) which as far as I know, at the time, there was only one for php, Prado (Yii - started in 2008 is too but based on Prado) I wrote this software 2005, there wasn't enough support Prado and I didn't want to use java. Plus I was switching from Win / Cold Fusion / Oracle to UNIX / PHP / MySQL. (I had enough of the Allaire to Macromedia change then heard through the grapevine (I was a CF beta tester for MM) that Adobe was taking over. And after paying an arm and a leg to buy the NT, CF and Oracle server licences since 1999.) And as far as my "composer" program I actually wrote that way before composer came out, I just added the anti hacker, anti scraper and any filename extension features, because I don't want to babysit the clients servers and some of my clients use api's that charge per web request and that gets expensive when someone scrapes their site. And I will apologize for my choice of words.... I should have said "a few rude" instead of "many rude". There are many nice people on this site. But as the saying goes... it only takes one bad apple... I used to be on here helping people, not just asking questions... So it's not that I'm attracting rude people, I have seen it. So for the record... Since you are a Administrator...You can delete my account... Or will you need a framework first? Quote Link to comment https://forums.phpfreaks.com/topic/284880-looking-for-a-good-oop-mysqli-class-with-docblocks/#findComment-1463069 Share on other sites More sharing options...
Solution ignace Posted December 25, 2013 Solution Share Posted December 25, 2013 (edited) Well I am truely sorry that you only have 1 page projects. I was under the assumption you did real projects. My bad, in that case you are completely right. Carry on. Edited December 25, 2013 by ignace Quote Link to comment https://forums.phpfreaks.com/topic/284880-looking-for-a-good-oop-mysqli-class-with-docblocks/#findComment-1463070 Share on other sites More sharing options...
gizmola Posted December 25, 2013 Share Posted December 25, 2013 rbrown, Once again, nobody cares if you visit, and I absolutely will not be deleting your account, nor will anyone else. Previously you referred Ignace to the TOS, so I'm assuming by that you might have read them yourself? 10. By no means will any staff member change a user's account name or delete a user account. So do not ask. I looked back at some of your past posts, and I didn't see any place where you were helping people. I did see a post from a year ago where people were getting frustrated with you, as they tried to explain the basics of using foreach loops, and again you seemed to be willfully ignoring their advice. In terms of your reply, Ignace did read your question, and attempted to reply to you. Then you stated that you had found a library on github, but it had bugs, although it was good enough for you to base your own personal version of the library on. At that point, you got the NIHS link. At no point did anyone tell you to use a framework. Doctrine2 was brought up, which is an ORM, not a framework, and is architected in a way that the data access interface (DBAL) provides everything you asked for. You indicated you never heard of it, but you would look at it, and Ignace helpfully provided a link and the composer section that would have allowed you to evaluate just the DBAL portion of Doctrine2 in a few minutes. Then you reply: I'm not using Composer, I wrote my own Composer type program. I started writing my own mysqli wrapper. Then I can add other stuff if I want too. the closest one I found to what I'm looking for is on github: bennettstone/simple-mysqli There are some programming errors in the class. But it gave me a few ideas on how I'm going to do mine. At this point, Ignace and just about everyone else around here, is going to throw in the towel, because it's clear you are close minded, and not interested in learning about anything new, or that doesn't shoehorn into your view of the world. You're dismissing them without even understanding what they are. Furthermore, you started a thread asking for a simple mysqli wrapper library, and 2 replies later YOU'RE WRITING YOUR OWN!!!!!!!!! I could write a bunch of irrelevant drivel about languages I've used in the past. Does the fact that I've written turbo pascal, c and c++, 808x asm, and gupta sql windows code in the past (not to mention Coldfusion and Perl based web apps) have anything at all to do with the state of PHP development in 2013? In 2013, composer is something you absolutely have to be using if you're doing professional php, but if you're dead set on only doing the things that you found worked for you back in 2005, so be it. Quote Link to comment https://forums.phpfreaks.com/topic/284880-looking-for-a-good-oop-mysqli-class-with-docblocks/#findComment-1463078 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.