Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
On 10/9/07, Tony Marston [EMAIL PROTECTED] wrote: Nathan Nobbe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 10/9/07, Tony Marston [EMAIL PROTECTED] wrote: Nathan Nobbe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 10/9/07, Robert Cummings [EMAIL PROTECTED] wrote: Why would I use an interface? :) because inheritance is not always optimal. I have never found a prolem when using an interface was the only solution, or even ANY kind of solution. The fact that your designs need it speaks volumes of the problems with your designs. im not the one whose been defending my designs in this conversation; you are. But you are the one who keeps saying that your approach, where all member variables are hidden, is far superior. I'm just saying that I do share that opinion. there are plenty of situations where the interface is the more elegant approach, thats why its here; and thats why it was added in php5. There's your problem, then. You are wasting your time trying to implement fancy design patterns just because design patterns are supposed to be cool. i dont recall reading any suggestions to use design patterns because they are cool. But you are the one who pointed out that interfaces are used in design patterns, therefore they *must* be OK. I am saying that I have never seen any advantages from using interfaces, and I don't waste my time with design patterns. infact the advice ive read is to only use them when they make sense. My point is that interfaces do not make anysense to me at all. I can access all my class methods without them, so what benefit do they give? Loader class, Controller Base class, Front Controller - I have none of that crap in my code, so I don't encounter the problems you have. When I see code like $this-load-library('email') I just thank my lucky stars that I don't have to maintain it. I think some serious refactoring is long overdue. id have to say code igniter is quite a bit more popular than radicore. maybe youre the one who has some refactoring to do. Perhaps you are trying to implement something from another language and expecting PHP to be just like that other language, which is always a stupid mistake. PHP is different, therefore the solution will be different. I suggest you learn how PHP works and design accordingly, and stop trying to force it into emulating another language. well php has certainly gotten its influence from a number of other languages. where do you think the additional features in php5 got their inspiration from? Some of those features were implemented just because some a*sholes who are more familiar with other languages keep saying I can do so-and-so in language X, and I want to do exactly the same thing in PHP. Language X has interfaces, so PHP *must* have interfaces, Why? What purpose do they serve? What benefits do they bring? btw; heres the definition of implement from dictionary.com im·ple·ment https://secure.reference.com/premium/login.html?rd=2u=http%3A%2F%2Fdictionary.reference.com%2Fbrowse%2Fimplementation /n. '?mpl?m?nt; v. '?mpl??m?nt, -m?nt/ Pronunciation Key - Show Spelled Pronunciation[n. *im*-pl*uh*-m*uh*nt; v. *im*-pl*uh*-ment, -m*uh*nt] Pronunciation Key - Show IPA Pronunciation -noun 1.any article used in some activity, esp. an instrument, tool, or utensil: agricultural implements. notice the use of article; ie data; ie; you are wrong about member variables not being part of a classes implementation. if a variable local to a function can be considered part of its implementation; then a variable local to a class can be considered part of its implementation; its that simple. Implementation is still an activity or a procedure. A lawnmower is a tool which implements lawnmowing, and it acts upon a lawn. However, the lawn is not part of the implementation, it is the subject of the implementation. An object may contain both variables and operations, but the data is not part of those operations, it is the subject of those operations. -- Tony Marston http://www.tonymarston.net http://www.radicore.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php In response to: My point is that interfaces do not make anysense to me at all. I can access all my class methods without them, so what benefit do they give? We first sought to use interfaces in our new app when we were at the Best-Design-Ever stage but scaled them back more and more at each step of the development. We have pretty much completed the first version of the app (which contains maybe 90% of projected capability) and interfaces have pretty much been reduced to shells whose only purpose are to fake types to make error checking bearable. For example we have a rating plugin to which you can pass anything that implements the CanBeRated
Re: [PHP] Interesting Rails Vs. PHP article
That's actually a very good article and while I don't agree with some of it (most notably #6, the I love SQL.. I find a good ORM layer to be a life saver should you ever need to make database structure changes without having all your apps collapse all over themselves), I certainly agree with the main idea: that rails is an excellent teacher. My current job is writing PHP code but I once completed a project with rails and strongly believe that I'm a better PHP programmer because of it. Rails is basically a very nice implementation of a whole bunch of enterprise patterns DONE RIGHT! I tend to associate the term enterprise with slow, bloated, overly complicated and barely functional but in this case, the enterprise patterns implemented are all worth knowing. We have our own simple framework that's quite fast and does nothing more than it needs to. It allows us to write new functionality very quickly and easily. The place I work has more programmers experienced with php and therefore it just made sense for me to learn PHP instead of them all learn Ruby. I still routinely recommend they try rails at least one, on their own, just for the hell of it because they'll be so much better afterwards. It's easy to do things the wrong way in PHP but it's pretty hard with rails. It pretty much forces you to do things properly and while that can be maddening at first it's worth the effort. On 9/23/07, Colin Guthrie [EMAIL PROTECTED] wrote: Thought ppl here may be interested in this: http://www.oreillynet.com/ruby/blog/2007/09/7_reasons_i_switched_back_to_p_1.html Originally linked from /.: http://developers.slashdot.org/article.pl?sid=07/09/23/1249235 Col -- 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] php personal project
* Disclaimer: The following may sound condescending (I hope not) but you said you're a newbie so I'll try to start with the very basics. For your database tables questions you basically want the tables to represent real life things. For example, a player, a team, etc. So let's make a quick list of things you might want to store information about: Players (an NFL player) Teams (a NFL team) Coaches (a NFL coach) Fantasy Owners (one of your friends who has a fantasy team) Now that we have that list we have to decide what information we want to keep about each. For example a player will need a name, an age, a salary, possible other stuff that's unique to him alone. Same for teams, coaches and fantasy owners. Now that we have a little information about each we need to decide how to link everything together. In order to properly link things together (to keep each database record (or row) unique) we need to give each record a unique id. An auto-incremented integer serves perfecly. So we'll have player_id, team_id, coach_id, owner_id. Teams have many players but players only play on one team. In this case we have a one to many relationship between teams and players. In this case you want to store the team_id in the player table. The relationship between fantasy owners and players can be more complicated however. Depending on the rules you set up owners will surely have several players but players may be owned by several owners. Here we have a many to many relationship. In this case we need what's called a middle table, basically a table whose sole purpose is to link 2 other tables together. We'll call this table owners_players and it will only have 2 fields: owner_id and player_id. So when you want all players on an owner's team you select * from owners_players where owner_id = x and with each of those results you look up the player's information from his unique id (though it's easier to do a join but I don't want to get into table joins right now that's more complicated). I've shown the two more complicated types of relationship but there's still another: one to one. In this case you can put the id of the linked-to record of the other table in either table, it doesn't particularly matter, put it where you think it makes most sense. This should be enough to at least get you started collecting some data. On 9/21/07, Karl james [EMAIL PROTECTED] wrote: Team, I am in need of some help. I would love to get some assistance on this. I need to start creating a database for my website. This will be for a fantasy football league website. To store stats on the database for archive purposes, And be able to pull them out on html reports. I want to do something similar to this site here. http://www.webleaguemanager.com/demo/reports/FantasyStandingsRpt.html Please review the reports page on the left. I want to do all except for real time scoring. Do not have the monies to purchase that yet, LOL. I will be extracting the data from other sites, like NFL.com and ESPN.com I know I need to create the players, members, stats tables. But, I am not sure how to set them up correctly. I can send you all a word file if you private message me. It will show what I am looking for. Here is a link on my wish list at the moment. http://www.theufl.com/ufl_project.htm I want to do all the work. I basically just need a instructor to help me along the way To, the end. I seem to never get any one to help me on this. Maybe, because I am A newbie and not sure what to do or what right questions to ask as well. Any help in this ordeal would be greatly appreciated. I have NO TIME TABLE on this. Just, a personal goal of mine for me and my friends. Please help me through this! :-) Karl James [EMAIL PROTECTED] www.theufl.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to implement a plugin system?
A couple of months ago I asked pretty much the same question on this list because I was doing the same thing. This is how we implemented our system. For starters, we rolled our own MVC framework. It's pretty much a standard MVC framework, very rails inspired but much more lightweight than Cake and with very strong support for ajax because we do a lot of it. We also decided to develop a large part of our functionality as plugins. For example pagination is a plugin. You can just develop your page and then paginate it pretty much as an afterthought by simply including a plugin to which you pass your array of objects (we have an ORM layer so we always deal with objects, not SQL) and the total number. Plugins are simply a folder in the plugins directory. This way the framework can autoload them easily. If you have a Poll plugin you need a PollPlugin class in the plugin/poll/classes directory. We also use the savant3 template engine so from here you probably also want a few templates to render your poll according to certain details. To display a poll on a page all I have to do in the controller is this: $poll = PollMapper::get()-findRandomBySite($ma-site()); $member = AFramework::framework()-user(); $poll_plugin = Plugin::load(poll,$poll, $member); $ma-view()-assignRef(poll_plugin,$poll_plugin); and in the view I simply class $this-poll_plugin-display(); and it displays correctly at that location. The interesting part there is the Plugin loader. Basically it's a pseudo constructor. You give it a plugin name that you want to load and any extra parameters (as many as you want) will be passed along to the class' load method which serves as the pseudo constructor. Since a poll object and a member object were passed to the poll plugin, I can check whether this member has voted before of not. If not, display() is going to return the p_poll_options template, otherwise it will return the p_poll_results template. That's really just some barebones html (a couple of divs with widths) that have a default styling you can include (in the plugin's css folder) or that you can override in the template that you're including's css. I just mentioned that each plugin can have its own css but it can also have its own images and javascript. Anyway, this method has been working out extremely well for us. It gives a lot of flexibility when you can just develop a self contained piece of functionality and then just include it anywhere on any page. If you make your plugins generic enough to handle anything (like update lists that can take arrays of arbitrary object and just display them correctly as a paginated list) you'll find this method works very well. On 8/7/07, Hamza Saglam [EMAIL PROTECTED] wrote: Nathan Nobbe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 8/6/07, Stut [EMAIL PROTECTED] wrote: Hamza Saglam wrote: Thanks for your response. However I am looking for something a bit more comprehensive :) I could do it as you suggested if I had only a few plugins. As I am going to add loads of plugins over the time, rather than adding all the plugins one by one, could something like a 'loader' class be implemented? What I mean by that is, it will take the requested plugin names (with their own parameters necessary) and load/initialise them. In semi-psuedo-code, it would be something like: foreach plugin suplied as the argument include the plugin initialise it end Perhaps I should change the question to: Do you think something like this would be efficient and useable? If not what sort of pattern would you follow? What you're describing is the Factory pattern, and yes that's the most efficient way to implement plugins. You should never load classes unless you need them - it's a complete waste of time, and definitely not recommended if you're going to have a lot of plugins. I would suggest you name your plugins X_plugin, Y_plugin and Z_plugin (where plugin could be anything) because that adds a level of security. Otherwise you could open yourself up to security issues because the user could instantiate any class in your system. -Stut -- http://stut.net/ Borokov Smith [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hey Hamza, require_once($chosenPlugin . '.class.php'); $obj = new $chosenPlugin(); return $obj; And you can start from there. hth, boro Hamza Saglam schreef: Hello all, I am working on a project which needs to have some sort of plugins architecture and I am kinda stuck. Basically I want to give a list of items to the user, and according to his/her selection, I want to load relevant functionality into my application. I was thinking of having an abstract plugin class, and have the plugins implement that but then how would I actually load the plugins? Say for instance I want to load plugins X,Y,Z
Re: [PHP] PHP P O K E R...... and JAVA (convert)
This isn't exactly what was asked for but when I TA'd the principles of programming languages course, an assignment I gave was to write a simple poker game in Haskell. If anyone's interested here's the sample solution I gave: http://smokinn.tengun.net/comp348/poker.hs It's all console based of course. You'll need either ghc or hugs installed to run it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Interesting article about PHP security exploit by GIF files
Thanks for the link. I got worried for a second that my code could be exploited so I did a quick check to make sure that mime-types were correct. (I check the mime type to make sure it's an image, not the file extension.) I renamed a .jpg file .jpg.php and uploaded it and got application/x-php as a mime type. Is there a way to fake the mime type of what you've uploaded so that this exploit is still possible? Should I be checking both mime types and file extensions? Thanks On 6/20/07, Daniel Brown [EMAIL PROTECTED] wrote: On 6/20/07, Jochem Maas [EMAIL PROTECTED] wrote: Daniel Brown wrote: On 6/20/07, Tijnema [EMAIL PROTECTED] wrote: Hi all, Just received a mail from phpclasses, which pointed to this very interesting article[1]. Seems good to know for starters ;) The experts around here probably already know this way of exploits. Tijnema [1] http://www.phpclasses.org/blog/post/67-PHP-security-exploit-with-GIF-images.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I've been doing stuff like that for legitimate reasons for about two years I thought everyone knew about it. exactly what are those legitimate reasons for uploading and executing php on other peoples server with authorization? :- my defense lawyer might be interested ;-) No, not the upload and execution, per se, but rather using images to contain processable PHP code. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- 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] Php script diagnostic app?
Thanks a lot for that post Paul. It brings up a question though. You said to never ever use that on a production server (an important disclaimer!) so I was wondering what people here used to log and simulate loads. I've used OpenSTA ( http://opensta.org/ ) and I was pleased with the results but it only works with windows. What do you guys generally use under linux? Just squid? Something else? I suppose I can just set up a windows box if I have to since OpenSTA acts as a transparent gateway but if there's a good linux solution out there for recording usage and playing it back concurrently I'd like to hear about it. With OpenSTA to create a test script it's as easy as clicking the record button to create the script and stop when you're done. Then you can go in and manually edit the script if you like and you can play it back as many times as you'd like concurrently (thereby simulating many users). Anyone know of anything like this? Thanks On 6/18/07, Paul Scott [EMAIL PROTECTED] wrote: On Mon, 2007-06-18 at 06:39 +0200, Paul Scott wrote: If you would like a more detailed HOWTO, please let me know, and I will write up something for you. http://fsiu.uwc.ac.za/index.php?module=blogaction=viewsinglepostid=gen9Srv59Nme5_9262_1182142431userid=3897070607 --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- 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] does this code look like it would check a file extensions, and disallow php files or exe files to be attached
On 6/14/07, dave peaachepea [EMAIL PROTECTED] wrote: ?php $filelinks=t3lib_div::_POST('file_name'); // the posting of the file name $exttypes = php3,php,exe; // list of extensions that shouldnt be used $fileextension = substr($filelinks,0,strpos($filelinks,.)); //get the extension after the . if ($fileextension == $exttypes['php']['php3']['exe']) { //if the file extension equals php, php3, or exe echo mime type doesn't work; //if the extension is php, php3, exe, than echo doesn't work } if ($fileextension != $extypes['php']['php3']['exe']) { //if the file extension doesn't equal php, php3, or exe than // store the file $filelinks = $this-storeFile(); } ? I'm not a programmer, and I'm very new at php so im sure there are errors and stupid logic in my code. It would be greatly appreciated if anyone here could critique and rip apart my code. thank you, -dave Since you're new to programming you probably haven't heard of regular expressions. They come in very handy in a case like this one. $files = array(test.htm, test.php, test.exe, test.jpg, test.jpg.exe, test.exe.jpg); $forbidden_extensions = array(php3,php,exe); foreach($files as $file) { preg_match(/.*\.(\w+)$/, $file, $extension); if(in_array($extension[1], $forbidden_extensions)) { echo File $file is not allowed br /; } else { echo File $file was uploaded br /; } } This will produce the output: File test.htm was uploaded File test.php is not allowed File test.exe is not allowed File test.jpg was uploaded File test.jpg.exe is not allowed File test.exe.jpg was uploaded a regular expressions is enclosed in / / . matches anything and a * means 0 or more. So the regular expressions starts matching 0 or more of anything. Then I escape the . ( the \. part) to match a . and then I put parenthesis to create a capture and \w means alphanumeric characters and + means 1 or more. The $ means the end. So that regular expression looks for a . followed by alphanumeric characters and returns those alphanumeric characters. If you didn't understand everything in there that's fine, just read this: http://www.regular-expressions.info/tutorial.html . It's an excellent regular expression tutorial and after reading it you'll see what was going on. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php / mysql performance resources
Hi everyone, Can anyone recommend any good books/resources for php and mysql performance management? I'm more interested in the software development side (as opposed to server configuration) of things. I'm looking for anything that would be good to know when working on websites that get millions of hits a day. Also, if anyone knows of any resources/discussions that illustrate the relative performance of joins vs multiple selects I'd love to check it out. Thanks, Guillaume -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php / mysql performance resources
Thanks for the response. On 6/13/07, Robert Cummings [EMAIL PROTECTED] wrote: On Wed, 2007-06-13 at 10:36 -0400, Guillaume Theoret wrote: Hi everyone, Can anyone recommend any good books/resources for php and mysql performance management? I'm more interested in the software development side (as opposed to server configuration) of things. I'm looking for anything that would be good to know when working on websites that get millions of hits a day. Also, if anyone knows of any resources/discussions that illustrate the relative performance of joins vs multiple selects I'd love to check it out. JOIN will almost always be faster by virtue of the query being optimized and doing the work within a single request. Really? I thought the way it worked was that when you joined 2 tables it needed to create every row combination applicable and then apply the where clause. In large tables wouldn't this be slower? It's these kinds of optimizations and when the kick in, etc that I don't know much about. In our application we wrote an abstraction layer with lazy loading. (eg: If a User has a Profile the db users table has a profile_id and we create a ProxyProfile that only has an id and will look up its other attributes in the db if ever needed and then replace its reference by a full Profile object.) Because of this, so far the entire app only has 1 join because the other select(s) will only be done if and when they're needed. I'm certain this is faster in the average case but I wanted to know which is generally faster in case I later profile the code and see that in some cases the dependent item is pretty much always loaded. JOIN couples two table together. JOIN simplifies the data retrieval and code. MULTIPLE SELECTS allows you to join the data yourself, possibly almost as fast as the database. MULTIPLE SELECTS allows the tables to reside in different locations. MULTIPLE SELECTS can be faster than a JOIN if your database is under heavy load and you place the tables on different servers allowing the PHP process to do the joining work. PHP processes scale horizontally better than database servers. The db will be under heavy load (once we deploy) but we don't yet intend on distributing the database. We did however plan for it since in the scenario I described above we just need to create a different db connection for a different table. We could theoretically have as many different db servers as tables (except for that one join of 2 tables). MULTIPLE SELECTS are usually add complexity to your code. We dealt with this in our design.. The actual front-end functionality is all simply object-oriented programming so I can muck around as much as I want with the ORM layer without affecting any of anyone else's code. (As long as I don't change the published interface of course!) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php / mysql performance resources
On 6/13/07, Richard Lynch [EMAIL PROTECTED] wrote: On Wed, June 13, 2007 12:31 pm, Guillaume Theoret wrote: Thanks for the response. On 6/13/07, Robert Cummings [EMAIL PROTECTED] wrote: On Wed, 2007-06-13 at 10:36 -0400, Guillaume Theoret wrote: Hi everyone, Can anyone recommend any good books/resources for php and mysql performance management? I'm more interested in the software development side (as opposed to server configuration) of things. I'm looking for anything that would be good to know when working on websites that get millions of hits a day. Also, if anyone knows of any resources/discussions that illustrate the relative performance of joins vs multiple selects I'd love to check it out. JOIN will almost always be faster by virtue of the query being optimized and doing the work within a single request. Really? I thought the way it worked was that when you joined 2 tables it needed to create every row combination applicable and then apply the where clause. In large tables wouldn't this be slower? It's these kinds of optimizations and when the kick in, etc that I don't know much about. Conceptually, JOIN builds that monster table. If the DB engine can figure out how to constrain one table or another BEFORE that JOIN to give a much smaller record set, and if they have mathematical proof that the end result is the same, then they will optimize and go with the smaller set when possible. That's a (very) good thing. Yes, very good indeed. I don't envy the people that write the algorithms to figure that stuff out. I do still remember my relational algebra but wouldn't know how to go about implementing that as efficiently as possible! In our application we wrote an abstraction layer with lazy loading. (eg: If a User has a Profile the db users table has a profile_id and we create a ProxyProfile that only has an id and will look up its other attributes in the db if ever needed and then replace its reference by a full Profile object.) Because of this, so far the entire app only has 1 join because the other select(s) will only be done if and when they're needed. I'm certain this is faster in the average case but I wanted to know which is generally faster in case I later profile the code and see that in some cases the dependent item is pretty much always loaded. You really should write the code the most straight-forward way you can, and then optimize after identifying bottle-necks. Anything else is just optimization-masturbation. We wrote this specifically to keep things conceptually simple. It's much easier to write an ORM layer and then use nothing but objects without worrying about the db in the application layer. The result of writing the ORM layer the way we did was that joins pretty much vanished (because of the lazy loading). I was just curious as to how good this actually was. It also makes it much easier to profile and make changes if necessary too. The db will be under heavy load (once we deploy) but we don't yet intend on distributing the database. We did however plan for it since in the scenario I described above we just need to create a different db connection for a different table. We could theoretically have as many different db servers as tables (except for that one join of 2 tables). This is the scary part. You really ought to set up a QA server with simulated heavy load for real life testing, rather than waiting until you deploy to experience heavy load. It's not as scary as it sounds. What I'm working on is pretty much a re-write of our current system (with many new features) and it runs off a single db server. We do expect the load to increase over time though (we currently get around 500 to 700 000 hits a day I think) so it's good to plan for growth. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php / mysql performance resources
On 6/13/07, Daevid Vincent [EMAIL PROTECTED] wrote: I'll throw in my suggestion here as to how I implement this. Generally I evaluate how big are the tables and what do I intend to do with them. Sorting is usually a problem. Using the PHP multi_sort seems cumbersome and never seems to be as simple as letting the DB do it. I too use LEFT JOINs frequently. If I have to join more than say 4 or 5 tables, I start to break it up. My favorite little trick is to load a PHP array with smaller tables. [Pseudocoded:] $employeeType = array( SELECT id, name FROM employee_type_table ); And I might do this for several tables. (you can also store these in a $_SESSION if you're using these key/values frequently on different pages) Then this can effectively eliminate one whole join (per), as most tables key off of ID's (duh). Then do my real SELECT/JOIN query, and during my while/$row loop I just substitute the array value back in like this ?= $employeeType[ $row['employee_type_id'] ] ? I actually use this little optimizing trick as an interview question for new hires. You'd be amazed at how many people don't think of this, as obvious as it seems to me... That's a neat trick, I'll try to keep it in mind. In our current setup we'd do something like: [pseudo] while($row) $employee = find::($row['employee_id']); // Return an Employee object echo $employee-getType()-getName(); So here, when we created an employee object, it did a db hit and looked in the employees table. The type attribute for employee was just a ProxyType object (with an id that was stored as type_id in the employees table). When I tried to access the name the ProxyType did a db hit and replaced itself with a Type object that had all the columns of the types table as its attributes. If we needed to later access some other attribute of the employee's type, no db hit would be made since it's now loaded. In this case, if you're looping over all employees and outputting their type names you'd be doing nearly twice as many db hits with my method. Thanks for the tip. D.Vin -- 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] Resources for plugin based frameworks
This is mostly for anyone that could later read this thread, (probably when searching) but I found an excellent article titled Developing a Plugin Architecture for PHP Applications in the april 2006 issue of the php|architect magazine. On 5/14/07, Greg Donald [EMAIL PROTECTED] wrote: On 5/14/07, Guillaume Theoret [EMAIL PROTECTED] wrote: I'm about to start a project and I'm still in the architectural design phase. It's going to be a content management system but for several unrelated things such as website management, employee management or project management. I plan on building a module based system where each part can be developed as an individual plugin and then just added into the portal/main page. Does anyone know of any php-specific resources (either online or paper format, both are fine) that would be helpful? If PHP is required I would suggest Drupal. It's a really good CMS with a solid plugin/module architecture. The API is very well documented. -- Greg Donald http://destiney.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] Resources for plugin based frameworks
Yeah, sadly it's not free. When I found it I asked my manager if we could subscribe and it turns out he already subscribes so we went to his place at lunch and brought his copies over here. Now we're getting a subscription for the office. On 5/15/07, Jim Lucas [EMAIL PROTECTED] wrote: Guillaume Theoret wrote: This is mostly for anyone that could later read this thread, (probably when searching) but I found an excellent article titled Developing a Plugin Architecture for PHP Applications in the april 2006 issue of the php|architect magazine. On 5/14/07, Greg Donald [EMAIL PROTECTED] wrote: On 5/14/07, Guillaume Theoret [EMAIL PROTECTED] wrote: I'm about to start a project and I'm still in the architectural design phase. It's going to be a content management system but for several unrelated things such as website management, employee management or project management. I plan on building a module based system where each part can be developed as an individual plugin and then just added into the portal/main page. Does anyone know of any php-specific resources (either online or paper format, both are fine) that would be helpful? If PHP is required I would suggest Drupal. It's a really good CMS with a solid plugin/module architecture. The API is very well documented. -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php nm, stupid of me to not search and find out why first :( -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Unknown -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Resources for plugin based frameworks
Hi, I'm about to start a project and I'm still in the architectural design phase. It's going to be a content management system but for several unrelated things such as website management, employee management or project management. I plan on building a module based system where each part can be developed as an individual plugin and then just added into the portal/main page. Does anyone know of any php-specific resources (either online or paper format, both are fine) that would be helpful? Thank you, Guillaume -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php