Archive for October, 2009

PHP: require and include

Author: Jeremy Smyth

Another simple feature that’s good to pick up on!

When you want to run the same functions from several pages, but don’t want to copy/paste (because that’s BAD), you do this.

Usually, you’d use require or include to include the code from one PHP script in another.

If you hadn’t done this before, or designed it in, you’ll probably need to extract the functions from your script(s), place them in a central file, and include that in all scripts that need it (including, of course, the one they were originally in!). Remember that includeing a file in another causes its embedded HTML to be included too, so you’ll typically include PHP files that have functions only, to achieve the desired result.

Then you just call the function, as if it were written in the script in the first place :)

SQL Server: Database Diagrams

Author: Jeremy Smyth

A little feature that some people don’t know about but would find very very useful: database diagrams in SQL Server. If a picture paints a thousand words, then this feature will help you pick up on the structure of data much more easily.

Within SQL Server, there’s the “Database Diagram” container in each database, in Management Studio.

You can create a new diagram in there, and include all (or some) of your tables, so showing where the relationships are, and what the tables are.

You could also create several different diagrams, each showing a subset of tables and relationships useful to a particular use case.

Quality of Service: Hosting

Author: Jeremy Smyth

There are several useful QoS parameters, although not all are as easily measured as e.g. 99.98% uptime, which is easily derived – 99.98% of the time, your server is available.

Some other useful metrics:

  • What sort of bandwidth do they support? How about if it’s a shared pipe and they’ve multiple high-volume clients? You’re unlikely to get an honest answer to this from the vendor.
  • If you’re on a shared host, what sort of competition for resources will you have on the box? Again, this is competitive information, so you’re unlikely to get an honest response.
  • How independent is each application? i.e. if another application on a co-hosted box loops MySQL, will your app suffer?
  • How often do they upgrade dependencies, and does that affect their 99.98% uptime?

Then there are the fluffy not-entirely-QoS related hosting problems:

  • Will they do your backups etc.?
  • How responsive are they to queries? Do they have a guaranteed response time e.g. 3 hours from first email to first response, 24/7?
  • Are they efficient? Have they resolved issues within a useful timeframe? A quick response-time is nice and feelgood, but if they don’t fix the problem, that’s not quite so good!
  • Are they patient with you when you suggest issues, but due to your own technical background are slightly off-base?

GROUP BY and single-row values

Author: Jeremy Smyth

So, you’ve constructed a SQL statement with a GROUP BY clause, and you’re getting this message:

Column col is invalid in the select list because it is not
contained in either an aggregate function or the
GROUP BY clause.

Bear in mind that the result of a GROUP BY statement, or of a statement where one or columns uses an aggregate function, has each row containing a summary of other rows.

This means that if you try to include a column in your select clause that isn’t a summary (this includes values by which you’re grouping), then the server is going to have difficulties returning it; remember, it’s going to return one row per group, and any value that can’t be reduced to a single row per group will fail.

This gets interesting even when you’re hoping to return a single value per group, for example with CASE.

If the CASE expression you’re using is dependent on values of individual rows rather than summaries, you’ll also get the above message; you may only reference non-aggregate values (i.e. single-row values) in an aggregate function, or in the WHERE clause, so the solution would involve placing your CASE inside an aggregate function, in this case your SUM.

The same applies for the HAVING clause, as it is effectively selecting rows in the grouped resultset based on values in each group.

Returning a copy of an object

Author: Jeremy Smyth

Consider an object passed (by reference) into a method, which then modifies the object. Should the method return the object on completion?

Well, it’s redundant. Here’s why.

There are two approaches to doing this – the classic way (caller chooses what to manipulate/change), and callee changes (which is what happens when you pass in an object by reference:

  • If the caller chooses what to manipulate, then your method will operate on a copy of the dataset, and return that copy, leaving the original untouched. Then the caller may overwrite the original, if desired. Many array operations in Perl work like this.
  • The alternative lets the called method do the in-place operation, in which case the return value is more typically a boolean (”Yes, I’ve succeeded!”) or an int containing the number of values affected. This is how database updates work.

Of course, if the object is not passed by reference (i.e. a copy is passed into the method) or if the method explicitly returns a modified copy, then returning an object is the right way to do it.

  • chad ochocinco career stats
  • bangles eternal flame mp3bengals forum
  • tea party lies
  • memo
  • vince young redskins
  • search engines for kids
  • randy moss combine results
  • chad ochocinco parents
  • arno
  • hp support quick test pro
  • astronomy
  • new england patriots underwear
  • new england patriots 1997 roster
  • dashboard
  • tea party table settings
  • bea exhibitors
  • c span 4 to 5
  • battleship hacked
  • hyosung
  • tea party zombies download
  • search 3 bodybuilding other index
  • bengals preseason schedule 2011
  • carwash
  • mtv rivals
  • bengals history
  • randy moss legal issues
  • zara phillips husband
  • vince young uncle rico
  • vince young dadvince young eagles
  • chad ochocinco and cheryl burke
  • trojans
  • search 50 cent
  • search engines other than google
  • chad ochocinco to detroit
  • la ink ink
  • textured
  • battleship aurora
  • tims
  • glaze
  • northfield
  • vince young released
  • canary
  • la ink 105
  • c span yesterdayc span zelaya
  • new england patriots espn blog
  • speak
  • new england patriots 3 4
  • zara phillips wedding date
  • fenwick
  • new england patriots gillette stadium
  • chicago bears 17 lisa lampanelli
  • federated
  • battleship ipad
  • infrared
  • comforters
  • tea party manifesto
  • chicago bears expo 2011
  • chad ochocinco quotes video
  • steering
  • bea per capita income
  • bengals arrests
  • disassembledis boards
  • nicu
  • dis quand reviendras-tu
  • dis tester
  • chad ochocinco ultimate catch cast
  • stronger
  • bengals undraftedbengals vs steelers
  • cspan ap government review
  • connecticut renaissance faire
  • powertrain
  • bengals hard knocks episode 1
  • hp support error 1005
  • c span youtube obama
  • hp support 6310hp support 7200
  • towns
  • tint
  • cspan facebook
  • la ink 3rd season
  • hangers
  • chicago bears gifts
  • vince young 10 11
  • digitizing
  • connecticut food bank
  • mtv executivesmtv fantasy factory
  • hp support contact number
  • tea party hobbits
  • greg olsen puzzles
  • bea 2011 map
  • chad ochocinco xpchad ochocinco youtube
  • bengals qb situation
  • randy moss college
  • c span shelby foote
  • pudding
  • zara phillips and the queen
  • rufus
  • tea party chicago
  • hp support chat
  • bea goldfishberg
  • randy moss 98 vikings
  • zara phillips school
  • dis pater
  • tea party 8 28 09
  • michelin
  • tea party medicare
  • sticky
  • chicago bears tattoos
  • chicago bears 08 record
  • vince young endorsementsvince young foundation
  • cspan presidents
  • battleship kirishima
  • search and seizure
  • zara phillips and the queen
  • mtv youtube channel
  • search 78search 800 numbers
  • battleship yamato wreck
  • mtv live
  • la ink phone number
  • tea party zombies download
  • beagle
  • battleship lexington
  • bengals merchandise
  • battleship excel
  • dist 95
  • greensboro
  • search xml file
  • dailymotion
  • bea fox
  • bea rims
  • hp support chat
  • bengals cats for sale
  • hp support id
  • bengals new uniforms 2012
  • polos
  • cspan washington correspondents dinner 2011
  • bridesmaid
  • vince young injury
  • xanadu bengals
  • randy moss korey stringer
  • chad ochocinco vs skip bayless
  • opera
  • bea 0b0 105
  • vince young yahoo stats
  • bengals insider
  • squadron
  • dis poem
  • vince young jay cutler
  • hp support 6500a plus
  • mtv 5 cover
  • nozzle
  • bea 4603
  • bengals forum
  • bengals football
  • hp support 530
  • battleship bismarck wreck
  • freida pinto jeansfreida pinto kissing
  • hp support hard drive replacement
  • mtv oddities
  • scored
  • tea party ribbons
  • christina
  • birthdate
  • vince young 6
  • mtv 90s music videos
  • zara phillips tongue
  • search vim
  • bea test
  • connecticut lottery
  • freida pinto 1995
  • randy moss vikings 2011
  • dis 2012 conference
  • vince young status
  • connecticut quarter error
  • dis boards cruise
  • connecticut state parks
  • new england patriots 07
  • search 5500
  • vince young z
  • search tumblr
  • vince young rumors
  • c span yesterdayc span zelaya
  • connecticut 97.7connecticut attorney general
  • bea oracle
  • randy moss bio
  • freida pinto boyfriend