RE: [PHP] Doctrine madness!
While I do agree with your discloser of the bloat for all off the shelf frameworks. I created my own framework and my development time drop drastically and not by a few hours, in some cases days. The complaint of time is always an issue, if you do not scope out a project properly. Timelines and IPR's (In Process Reviews) will keep the developers sane, and the customer happy. It tells the customer: I have given you expectation timelines on how long it will take me to get to each point in development. It also gives you an opportunity to find obstacles in development that can be discussed or redirected with another option before the project begins. Any added edge on the timelines, allows for extra creativity and pit falls. The worst thing you can do? Not take time to understand your development process and coding practices. To use someone else's framework is asking for trouble. Like most who download a framework, install it. They just setup the config and start programming. Bad, Bad, BAD If you took the time to flow through the framework, you might understand all the things you never want to happen that can cause serious latency issues. Then soon learn, you are better off just writing your own or developing a coding practice that keeps your timelines consistent. If you are using a database, PLEASE learn what is called Relational modeling. The fastest server in the world will not help a poorly designed database, causing 78% of all latency in projects that are DB driven. I never claimed to be the expert here, I just know what has made me very successful. Richard L. Buskirk -Original Message- From: Paul M Foster [mailto:pa...@quillandmouse.com] Sent: Friday, June 17, 2011 1:46 AM To: php-general@lists.php.net Subject: Re: [PHP] Doctrine madness! On Thu, Jun 16, 2011 at 08:53:18PM -0400, Eric Butera wrote: > On Thu, Jun 16, 2011 at 7:32 PM, Daevid Vincent wrote: > > [snip] > > I'm sorry but this is absolute rubbish. I used to write my queries by > hand, but over time you start to realize that perhaps, maybe writing > out thousands of identical lines of code over hundreds of projects > might not be an efficient usage of time. If you have performant > requirements, that is one thing and can easily be overcome with slight > deviations on a case by case basis. Most of the time, contrary to > your position, things just need to work and be completed quickly. > What is the more common question from clients: why is this so slow, > or, client asks why is this not finished yet? I generally side with Daevid on this, though my position isn't as extreme. However, I have to take exception to the "either/or" question from clients. As far as I'm concerned, clients need to learn that coding takes as long as it takes. I'd much rather spend the extra time and never have the customer ask why the code is so slow. The theoretical alternative, having the customer satisfied with the delivery time, but complain about latency, isn't what I'd consider acceptable. Looking at some of the code that comprises most ORM and other frameworks (but particularly ORM frameworks) the bloat is amazing. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to create an image with flowing text?
On 16 June 2011 23:59, Brian Dunning wrote: > Hey all - > > I need to create PNG images with transparent backgrounds that contain text. > The text will come from four fields in a database, and needs to be centered, > and text wrapped. The fields are going to be of varying lengths, so each > block of text (which will be shown in a different font size) will flow onto > an unknown number of lines, and I want to start the next line right below, > wherever it is. > > Unfortunately I have come up against some restrictions. > - I will not be able to use ImageMagick. > - I have Ghostscript, but only version 7.07. > - The server is Red Hat 4.x with PHP 5.2 and installing new software > is unlikely. > > Can anyone suggest a tool to make this easiest? > :-( > > - Brian Do you have the image extension loaded? A LONG time ago (nearly 7 years ago - just when I first started using PHP - so please forgive the code), I built a script to take words and scale them to fill a box. The technique of getting the size of the text could still be useful here. It was in response to a question on Experts Exchange (http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_21113446.html#a11972605) The code is awful by my current standards. But it worked. So there must be something in that. I'll send you the code directly as, frankly, it is embarrassing to see today. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Performance gain when not using prepared statements?
On Friday 17 June 2011 04:50:00 Daevid Vincent wrote: > > I've seen too many people over the years try and rally against common > > sense practices like using prepared statements for perhaps a marginal > > gain of performance on one page while their load averages are 0,0,0. > > Agreed. The ONLY time prepared statements are useful, is in a loop where > you're changing a few variables but within the same SQL statement. That is > a rare case for most people. > Not ONLY. I love prepared statements because with them I can store arbitrary strings in DB without need to worry about fancy escaping and SQL injection. And do it in DB-independent way. Think about all that extra escaping and performance gain of not using prepared statement will shrink a lot ) Don't have actual numbers though. -- Vitalii -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what kind of features would you like in php orms?
- defining the mapping schema in an alternate method than using meta data (I HATE them, I would prefer an XML file with a DTD so you could use autocompletion with IDE like NetBeans) - clear keywords in the schema - OQL can do UPDATEs - one and only one configuration file with everything in it (and with why not the schema) - to not forget to KEEP IT SIMPLE, specialised ORM that does everything already exists so there's no point in writing one! that's it for me (at least at the moment) Of course I would suggest to use PHP 5.3 specially for late static binding (and for people that love namespaces) On 17 June 2011 07:42, 李白|字一日 wrote: > and how to design such an orm in current state of php language? >
Re: [PHP] what kind of features would you like in php orms?
thanks, how about the abstraction of different databases? it seems PDO is still lack of functions of importance. I'm currently trying to design a automated model like django or activeRecord. it should be quiet simple and automated, i have managed to possibly create the whole database only once. but the abstraction of the database and subsequent manipulation seem far more complicated than the previous part i'm currently only support mysql and only support whole query at once. 2011/6/17 jean-baptiste verrey > - defining the mapping schema in an alternate method than using meta data > (I HATE them, I would prefer an XML file with a DTD so you could use > autocompletion with IDE like NetBeans) java's hibernate instead of python's exlir or ruby 's rail style ? mean no ActiveRecord? > - clear keywords in the schema > > - OQL can do UPDATEs > - one and only one configuration file with everything in it (and with why > not the schema) > - to not forget to KEEP IT SIMPLE, specialised ORM that does everything > already exists so there's no point in writing one! > > that's it for me (at least at the moment) > > Of course I would suggest to use PHP 5.3 specially for late static binding > (and for people that love namespaces) > > > > On 17 June 2011 07:42, 李白|字一日 wrote: > >> and how to design such an orm in current state of php language? >> > >
Re: [PHP] what kind of features would you like in php orms?
You could simply use like doctrine DBAL or an already existing one made specially for ORM, or you can design one and at the moment make it to use only MySQL PDO is actually good enough to do that, I know that the only thing I had to do in my ORM was to write a special class to translate some queries for MySQL (to be able to use LIMIT for objects instead of rows). On 17 June 2011 12:06, 李白|字一日 wrote: > thanks, how about the abstraction of different databases? > it seems PDO is still lack of functions of importance. > > I'm currently trying to design a automated model like django or > activeRecord. > it should be quiet simple and automated, > i have managed to possibly create the whole database only once. > but the abstraction of the database and subsequent manipulation seem far > more complicated than the previous part > > i'm currently only support mysql and only support whole query at once. > > 2011/6/17 jean-baptiste verrey > >> - defining the mapping schema in an alternate method than using meta data >> (I HATE them, I would prefer an XML file with a DTD so you could use >> autocompletion with IDE like NetBeans) > > > java's hibernate instead of python's exlir or ruby 's rail style ? mean no > ActiveRecord? > > >> - clear keywords in the schema >> > > >> - OQL can do UPDATEs >> > > - one and only one configuration file with everything in it (and with why >> not the schema) >> > > - to not forget to KEEP IT SIMPLE, specialised ORM that does everything >> already exists so there's no point in writing one! >> >> that's it for me (at least at the moment) >> >> Of course I would suggest to use PHP 5.3 specially for late static binding >> (and for people that love namespaces) >> > > > >> > >> >> On 17 June 2011 07:42, 李白|字一日 wrote: >> >>> and how to design such an orm in current state of php language? >>> >> >> >
Re: [PHP] Doctrine madness!
On Jun 17, 2011, at 3:05 AM, wrote: > While I do agree with your discloser of the bloat for all off the shelf > frameworks. > > I created my own framework and my development time drop drastically and not > by a few hours, in some cases days. > > The complaint of time is always an issue, if you do not scope out a project > properly. > Timelines and IPR's (In Process Reviews) will keep the developers sane, and > the customer happy. > > It tells the customer: I have given you expectation timelines on how long it > will take me to get to each point in development. > It also gives you an opportunity to find obstacles in development that can > be discussed or redirected with another option before the project begins. > Any added edge on the timelines, allows for extra creativity and pit falls. > > The worst thing you can do? Not take time to understand your development > process and coding practices. > > To use someone else's framework is asking for trouble. > Like most who download a framework, install it. They just setup the config > and start programming. > > Bad, Bad, BAD > If you took the time to flow through the framework, you might understand all > the things you never want to happen that can cause serious latency issues. > Then soon learn, you are better off just writing your own or developing a > coding practice that keeps your timelines consistent. > > If you are using a database, PLEASE learn what is called Relational > modeling. > The fastest server in the world will not help a poorly designed database, > causing 78% of all latency in projects that are DB driven. > > > I never claimed to be the expert here, I just know what has made me very > successful. > > Richard L. Buskirk I've taken pretty much the same approach. After trying several different frameworks, I found it frustrating that, other than the blog tutorial that each one has, I couldn't get any of them to work the way I wanted to. Granted, this was probably due to me wanting to dive right in and start developing larger sites as opposed to starting simple to learn the frameworks. The most frustrating thing for me was when something went wrong and trying to figure out what caused the problem. So, understanding MVC, I built my own framework and, just like you, have cut my development time down considerably! With a simple script, I can generate the files I need and I have a nice looking page in seconds. Of course, it doesn't do anything at that point but it has all my JavaScript and CSS files loaded, any page headers (such as images) displayed, and a menu bar (if the site requires it). I have really enjoyed writing my own framework and making it better throughout the years. It has saved me considerable time! Take care, Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance gain when not using prepared statements?
On Fri, Jun 17, 2011 at 4:55 AM, Vitalii Demianets wrote: > On Friday 17 June 2011 04:50:00 Daevid Vincent wrote: >> > I've seen too many people over the years try and rally against common >> > sense practices like using prepared statements for perhaps a marginal >> > gain of performance on one page while their load averages are 0,0,0. >> >> Agreed. The ONLY time prepared statements are useful, is in a loop where >> you're changing a few variables but within the same SQL statement. That is >> a rare case for most people. >> > > Not ONLY. I love prepared statements because with them I can store arbitrary > strings in DB without need to worry about fancy escaping and SQL injection. > And do it in DB-independent way. > Think about all that extra escaping and performance gain of not using prepared > statement will shrink a lot ) Don't have actual numbers though. > > -- > Vitalii > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > You can implement caching at so many levels of the app that using a prepared statement should be at the lower spectrum of your worries. It is too easy to forget calling escape whether it be for a DB or output to the browser as proven by all the various bug trackers and hacked websites across the net. Just to drive this point home, if you do a quick search on Secunia for 'SQL Injection' [1] you get 4,158 advisories. Worth the risk? http://secunia.com/advisories/search/?search=sql+injection -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Doctrine madness!
On Fri, Jun 17, 2011 at 3:19 PM, Jim Lucas wrote: > On 6/16/2011 3:15 PM, Nathan Nobbe wrote: >> what it really amounts to is php is good at doing 1 thing and 1 thing only, >> generating web pages. for anything else, including command line scripts >> that run for more than 30 seconds, choose an actual programming language or >> be prepared to deal w/ hacky, disgusting workarounds. >> > > Nathan, > > I would have to disagree with your statement about using PHP for applications > that take more then 30 seconds or CLI scripts. > > I have a daemon (read: scripts) that I wrote using PHP. It listens on a few > UDP > sockets and maintains an open connection to mysql. It receives server updates > and other client requests for data. When it receives a client update it > updates > a couple tables in mysql. When it receives a request from a server for data, > it > goes to mysql gets all needed data, compiles it into the format requested and > sends it down the wire. > > This daemon starts when my system starts up. As of this morning it has been > running non stop since Feb 28th (about 108 days). Between then and now it has > received over 35M server updates and over 1.8M client requests. I think it > gets > used a bit. > > So, to say that doing anything with PHP that takes longer then 30 seconds to > complete will require you to use hacky and disgusting workarounds is false. > > I have no hacks nor disgusting workarounds in my scripts. Combined the > scripts > total about 200 lines, over half of which is either comments or vertical white > space. > > It has been running pretty much non-stop since August 2007 with minimal > maintenance needed. > > Jim Lucas > Hello, Impressive stats and has me a bit intrigued! Just out of curiosity, does your daemon use a heavy amount of object orientation in it or is it mostly procedural codebase? Regards -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Doctrine madness!
On 6/16/2011 3:15 PM, Nathan Nobbe wrote: > what it really amounts to is php is good at doing 1 thing and 1 thing only, > generating web pages. for anything else, including command line scripts > that run for more than 30 seconds, choose an actual programming language or > be prepared to deal w/ hacky, disgusting workarounds. > Nathan, I would have to disagree with your statement about using PHP for applications that take more then 30 seconds or CLI scripts. I have a daemon (read: scripts) that I wrote using PHP. It listens on a few UDP sockets and maintains an open connection to mysql. It receives server updates and other client requests for data. When it receives a client update it updates a couple tables in mysql. When it receives a request from a server for data, it goes to mysql gets all needed data, compiles it into the format requested and sends it down the wire. This daemon starts when my system starts up. As of this morning it has been running non stop since Feb 28th (about 108 days). Between then and now it has received over 35M server updates and over 1.8M client requests. I think it gets used a bit. So, to say that doing anything with PHP that takes longer then 30 seconds to complete will require you to use hacky and disgusting workarounds is false. I have no hacks nor disgusting workarounds in my scripts. Combined the scripts total about 200 lines, over half of which is either comments or vertical white space. It has been running pretty much non-stop since August 2007 with minimal maintenance needed. Jim Lucas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysqli_query() returns NULL?
Hey everyone, After reading the documentation for mysqli_query(), I was lead to believe that on any error it would return false. However, through a stupid mistake, I discovered that when I specify an invalid value for the database link identifier (in my case, I accidentally passed an integer), instead of false I get a return value of NULL. Does anyone know why? Thanks! James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Doctrine madness!
Not the original poster's response, but here PHP daemons also run smoothly. Full fledged OO style programming, with a bit of a thought about freeing unused variables/objects (running since PHP 5.2 times) it runs smoothly and in couple of weeks of uptime only gains few MB of memory footprint. Not heavily but constantly used, does similar things as Jim's daemon. b. On 17 June 2011 21:23, Eric Butera wrote: > On Fri, Jun 17, 2011 at 3:19 PM, Jim Lucas wrote: > > On 6/16/2011 3:15 PM, Nathan Nobbe wrote: > >> what it really amounts to is php is good at doing 1 thing and 1 thing > only, > >> generating web pages. for anything else, including command line scripts > >> that run for more than 30 seconds, choose an actual programming language > or > >> be prepared to deal w/ hacky, disgusting workarounds. > >> > > > > Nathan, > > > > I would have to disagree with your statement about using PHP for > applications > > that take more then 30 seconds or CLI scripts. > > > > I have a daemon (read: scripts) that I wrote using PHP. It listens on a > few UDP > > sockets and maintains an open connection to mysql. It receives server > updates > > and other client requests for data. When it receives a client update it > updates > > a couple tables in mysql. When it receives a request from a server for > data, it > > goes to mysql gets all needed data, compiles it into the format requested > and > > sends it down the wire. > > > > This daemon starts when my system starts up. As of this morning it has > been > > running non stop since Feb 28th (about 108 days). Between then and now > it has > > received over 35M server updates and over 1.8M client requests. I think > it gets > > used a bit. > > > > So, to say that doing anything with PHP that takes longer then 30 seconds > to > > complete will require you to use hacky and disgusting workarounds is > false. > > > > I have no hacks nor disgusting workarounds in my scripts. Combined the > scripts > > total about 200 lines, over half of which is either comments or vertical > white > > space. > > > > It has been running pretty much non-stop since August 2007 with minimal > > maintenance needed. > > > > Jim Lucas > > > > Hello, > > Impressive stats and has me a bit intrigued! Just out of curiosity, > does your daemon use a heavy amount of object orientation in it or is > it mostly procedural codebase? > > > Regards > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Doctrine madness!
On 6/17/2011 12:23 PM, Eric Butera wrote: > On Fri, Jun 17, 2011 at 3:19 PM, Jim Lucas wrote: >> On 6/16/2011 3:15 PM, Nathan Nobbe wrote: >>> what it really amounts to is php is good at doing 1 thing and 1 thing only, >>> generating web pages. for anything else, including command line scripts >>> that run for more than 30 seconds, choose an actual programming language or >>> be prepared to deal w/ hacky, disgusting workarounds. >>> >> >> Nathan, >> >> I would have to disagree with your statement about using PHP for applications >> that take more then 30 seconds or CLI scripts. >> >> I have a daemon (read: scripts) that I wrote using PHP. It listens on a few >> UDP >> sockets and maintains an open connection to mysql. It receives server >> updates >> and other client requests for data. When it receives a client update it >> updates >> a couple tables in mysql. When it receives a request from a server for >> data, it >> goes to mysql gets all needed data, compiles it into the format requested and >> sends it down the wire. >> >> This daemon starts when my system starts up. As of this morning it has been >> running non stop since Feb 28th (about 108 days). Between then and now it >> has >> received over 35M server updates and over 1.8M client requests. I think it >> gets >> used a bit. >> >> So, to say that doing anything with PHP that takes longer then 30 seconds to >> complete will require you to use hacky and disgusting workarounds is false. >> >> I have no hacks nor disgusting workarounds in my scripts. Combined the >> scripts >> total about 200 lines, over half of which is either comments or vertical >> white >> space. >> >> It has been running pretty much non-stop since August 2007 with minimal >> maintenance needed. >> >> Jim Lucas >> > > Hello, > > Impressive stats and has me a bit intrigued! Just out of curiosity, > does your daemon use a heavy amount of object orientation in it or is > it mostly procedural codebase? > > > Regards Nathan, It is strictly procedural code. The basic concept of the code is that it starts up, and opens a connection to MySQL. Then using stream_socket_*() functions connects to a UDP sockets and waits for data. Once it receives data, it figures out what the request was for. Now, at this point, it pushed some data to MySQL, or it grabs the entire contents of the DB tables and formats it to return to the client. All along the way, I have debug statements that get sent to a log file in /var/log/... I currently have a CPU usage time of 435hrs 20.74minutes and memory usage of just over 6MB. Most of which is PHP itself. Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php