TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 05-05-2009, 05:33 AM   #1 (permalink)
The Contributor
 
Join Date: Feb 2007
Posts: 64
Thanks: 9
Killswitch is on a distinguished road
Default Array and object performance

I decided it was time to continue working on my CMS again and am working on finishing up what was missing, and re-working a few tasks.

I have a component layer, which basically handles all the content tasks. Think Joomla for a second, if your familiar with it. Basically, I check if any component is set, and require its file if so. If the component has auto_start defined as true, and it is a class, the CMS will automatically call it.

It used to pass about 6 objects to the constructor, the database abs, config, core functions obj, user obj, xml parser / cacher, and plugin object.

I do this to prevent the need to global vars, but I dont like so many vars passed. So, I decided to trim this down.

Before calling the component file, I packaged all vars into an array...

$system['database'] = $database;
$system['config'] = $config;
etc etc etc

Now I just pass this array to the constructor so its one var to deal with instead of setting and passing 6 or 7.

Now my question, is wrapping an object into an array going to really hurt performance? So far, the CMS is fairly large scale, but runs extremely fast. Very few queries are executed.. infact, before the plugin layer, no queries were executed if there was a cached page to load ( cache also has option to make CMS work as flat file, stored as XML docs ).

I want to keep the CMS running fast, and I didnt think an array with 6 or 7 keys would do much to performance, but wasnt sure. I als wasnt sure if writing ...

if($system['user']->id > 0) { ... }
if(!$system['database']->query($query)) { ... }

Anyone have any input on which direction would be the better choice?
Killswitch is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Easily Format JSON using PHP and Interpret using Javascript Wildhoney Advanced PHP Programming 13 02-01-2013 11:05 AM
Dingo Framework - ALPHA Testing Open! ETbyrne Show Off 97 10-18-2012 02:11 PM
Help search through file.... allworknoplay Absolute Beginners 10 03-22-2009 02:15 AM
[Tutorial] How to organize your classes | Part 1 Tanax Advanced PHP Programming 10 03-01-2009 10:08 PM
array to object Gibou Advanced PHP Programming 11 03-24-2008 06:07 PM


All times are GMT. The time now is 09:02 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design