Web Applications

14K

Solutions

14K

Contributors

Web applications are systems that run in browsers that perform functions normally associated with other client-based programs. One of the most commonly used web applications is email; instead of downloading individual emails to a local machine, the data is shown through a website. Other examples of web applications are collaborative systems like a wiki or an online game.

Share tech news, updates, or what's on your mind.

Sign up to Post

The world seems to conceive of a curious bubble separating IT from “the business.” More so than just about any other pursuit in the commercial world, people think of IT as some kind of an island.
0
Secure Your WordPress Site: 5 Essential Approaches
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Read the original post on Monitis Blog.



Believe it or not, the most important thing about the website of your business is not what’s on it but how fast it loads. Yes, that’s right! 

 

As you can see on this infographic (an oldie but goodie!), there is a clear relationship between web load speed and customer conversions. And unless you have money to burn, the assumption is that you’re in business to earn revenue (rather than just having a fancy looking website!).

 

Let’s say this another way. The faster a page loads the more likely customers will be to visit and do business on your site. The inverse is also true. The slower a page the less likely customers will be willing to wait around and engage with your brand.

 

While this seems fairly straightforward, it’s surprising how few business owners really get the importance of website performance and the role it plays in their overall strategy. It might be nice to have a trendy looking website, but if it takes 10 seconds to load visitors won’t hang around long enough to appreciate all the bells and whistles anyway.

 

It’s important that small businesses leverage the latest web performance insights to ensure that things are running as optimally as possible and that your customers are happy. At the end of the day, this is really all that matters!

 

In order to help keep your business in check, we list out below the top 10 things you should know about website performance today.



Website Speed Impacts Conversions & Sales 


There’s a direct connection between web load speed and sales conversions. Consider this metric: 1 in 4 visitors would abandon the website if it takes more than 4 seconds to load. And this one: A 2-second delay during a transaction results in shopping cart abandonment rates of up to 87%.

 

A few years ago e-commerce giant Amazon calculated that a webpage load slowdown of just one second could cost it $1.6 billion in sales each year. Any questions?



“Start Render Time” is a Key Metric 


Start Render Time has emerged as a key metric in web performance and is the first visual cue that something is happening on a website. The following statement gives some words of wisdom on this topic:


The median for Time to Start Render across the web is 2.5 seconds. Shoot for better.  The top 10% of sites on the web start render in less than 900 milliseconds — fast enough that the visitor doesn’t have time to think about the fact that he or she is waiting to see content.  That should be the goal.



Design Best Practices Can Become Your Worst Enemy


Increasing the size of your website’s size, images, third-party scripts, and style sheets come with a heavy price and can adversely affect performance. This is especially true in the world of mobile. Over 50% of all time consumers spend on retails site is on mobile devices, and more than 50% of consumers multiscreen during the purchasing.

 

Some of the worst design practices are evident when web pages are initially blank and then populate, the CTA is the last thing to render, popups block the rest of the page, or when you fail to adopt user experience into your design strategy.

  


Performance Impacts Shopping Behavior 


We get the importance of website speed on customer conversions and sales. But this impact is more systemic than you might think. Kissmetrics shows that 44% of online shoppers will tell their friends about a bad experience online. And 79% of shoppers dissatisfied with a website performance are less likely to buy from that site again.

  


Mobile Unfriendly Sites Drive Customers the Other Way 


M-commerce is huge, which is why having a “mobile first” website is critical to success. Mobile commerce transactions in the United States are expected to total $123 billion in 2016. $76 billion will be from tablets, while the remainder will be from smartphones. These same numbers are replicating themselves globally.

 

A study from Google several years ago showed that mobile-friendliness was a key factor in purchase decisions, with 67% indicating that a mobile-friendly website made them more likely to buy a product or use a service. In addition, 61% indicated that a bad mobile experience made them more likely to leave.

  


You Can Win with Website Analytics 


Web analytics can make all the difference in how you relate to your customers. The ability to track a single customer across your site and across multiple devices will ensure that you can tailor your brand to their needs.

 

For instance, you want to learn more about when and where they’re visiting from, what devices they’re using, what are their online activities, and other key demographics such as age. Gaining these insights will help your organization better understand what’s important to your visitors and how to personalize their experience.


  

Speed Increases SEO 


In April 2010 Google started using page speed as a ranking factor, meaning that faster pages would earn higher SEO rankings than slow ones. More recently, Google also announced that it’s moving in this same direction for mobile web pages. The point here is that you get rewarded for offering your customers a better overall experience; faster load time means higher SEO rankings.


  

Mediocre Web Hosting Can Increase Downtime 


When reviewing web performance, it’s important not to forget your web hosting service. Even though your provider may offer you unlimited bandwidth, does that mean shared service with other sites that ends up affecting your own web performance?

 

Are you experiencing downtime or bandwidth issues? If so, it’s worthwhile to review your hosting options to ensure you’re getting the most efficient service. Don’t be afraid to insist on 99.99% uptime.

 


Too Many Affiliate Codes & Ads Drain Performance 


Becoming an affiliate reseller and pushing ads to bring folks in is great, but too much of a good thing can also become bad . . . especially for performance. When you go overboard on ads and affiliate code, this can lead to high bounce rates and, in turn, can adversely impact your overall website performance.

  


Website Monitoring Is Key! 


There are significant advantages to adopting website monitoring – cost, scalability, efficiency, to name a few. Not to mention, this frees you up to focus on growing your business, which matters the most anyway.

 

When it comes to monitoring your website, you don’t want to shortchange yourself. Get the peace of mind you deserve by entrusting your business to a proven industry leader.



Sign up for Monitis FREE 15-day full-featured trial! Premium plan starting from $12/month only!



0
img source: http://www.thecoolector.co<wbr />m/steve-ta<wbr />lkowski-ma<wbr />rch-robots<wbr />/

Original post on Monitis Blog.



Web performance monitoring is broken into two camps: passive and active. Passive monitoring is defined as looking at real-world historical performance by monitoring actual log-ins, site hits, clicks, requests for data, and other server transactions.

 

This is the kind of monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 

Active monitoring is a more experimental approach. It uses algorithms to take current log data and predict future network states. A good example of active monitoring is synthetic transaction monitoring. This involves deploying behavioral scripts in a web browser to simulate the path a real customer (or end-user) takes through a website.

 

Synthetic transaction monitoring is especially important for eCommerce and other high traffic sites as it allows webmasters to test new applications prior to launch. Synthetic transactions are scripted in advance and then uploaded to the cloud as a transaction tests.

 

There are different scenarios where your business would need transaction monitoring in order to stay competitive today.



Entering a New Market 


Before introducing a new application to market you want to have line-of-sight on how real users will interact with that app. Synthetic transaction monitoring provides behavioral scripts that have the ability to simulate an action or set of actions to ensure your application can handle the projected load.

Another benefit of synthetic monitoring is that it helps you simulate what happens when you introduce your application to a new geography. It allows you to test and fix potential issues related to deployments in new regions such as connection speeds (DSL, cable broadband, fiber optics) before real end users arrive. 

 


Finding Issues Before Customers 


Synthetic monitoring helps you to set up baseline tests in order to measure the way your customers will interact with your websites, APIs, or mobile apps. This type of testing can provide direct feedback on performance degradation or availability issues. It also will help your team locate the root cause, engage the right experts, and fix issues before they impact the end users. 


 

Measuring Performance Impact of Third Party Applications 


Today’s websites increasingly rely on third-party features such as carts, ads, customer reviews, web analytics, social networking, SEO add-ons, video and much more to provide outstanding customer experiences. If there’s a weak-link in the chain, or one or more of these elements are not working correctly, it can adversely impact your site.

 

Synthetic transaction monitoring can greatly assist in helping to monitor your third-party applications while also alerting you to potential or real performance degradations and downtime impacts. This helps tremendously in providing line of sight on your service level agreements (SLAs) in order to hold the third-party vendors accountable. 

 


Testing New Features 


Synthetic monitoring is important at any stage of development, but is especially useful for testing your web, mobile, or cloud-based applications before deploying new features into production. During this stage synthetic monitoring can provide a set of baselines and thresholds that reveal any potential obstacles customers may encounter in the real world. 


 

Comparing Your Performance to Your Competition 


With synthetic transaction monitoring you can set up benchmark scenarios to see how your applications are performing over time. You can also benchmark your company’s performance against top competitors within a certain historical time frame or within a specific geographical region. This approach can be especially important for establishing your organization’s strategic outlook for the year as well as for preserving competitive advantage in the marketplace. 

 


Analyzing Your eCommerce Strategy 


If you’re in the eCommerce business, then synthetic transaction monitoring is especially useful for ensuring that your eCommerce strategy is firing on all cylinders. By setting up tests with synthetic monitoring you can get apprised, for instance, about when one of the steps in your website’s online transaction process is no longer working properly. By tracking and analyzing every click and swipe, synthetic transaction monitoring solution can help you to identify problems and prioritize fixes in your website to ensure that customers continue to have the kind of experience they’ve come to expect.

  


Evaluating New technologies 


Another important use of synthetic transaction monitoring is to assist in the choosing, testing, and optimization of new technologies within your production environment. For example, being able to test if a new CDN (content delivery network) is performing as optimally as possible compared to other known benchmarks will help your organization to decide which product or service will provide the most value to your infrastructure.



Sign up for Monitis FREE 15-day full-featured trial! Premium plan starting from $12/month only! 



0

This article was originally published on Monitis Blog, you can check ithere.



If you have responsibility for software in production, I bet you’d like to know more about it. I don’t mean that you’d like an extra peek into the bowels of the source code or to understand its philosophical place in the universe.  Rather, I bet you’d like to know more about how it behaves in the wild.

 

After all, from this opaque vantage point comes the overwhelming majority of maddening defects.  “But it doesn’t do that in our environment,” you cry.  “How can we even begin to track down a user report of, ‘sometimes that button doesn’t work right?'”

 

To combat this situation we have, since programmer time immemorial, turned to the log file.  In that file, we find answers.  Except, we find them the way an archaeologist finds answers about ancient civilizations.  We assemble cryptic, incomplete fragments and try to use them to deduce what happened long after the fact.  Better than nothing, but not great.

 

Because of the incompleteness and the lag, we seek other solutions.  With the rise in sophistication of tooling and the growth of the DevOps movement, we close the timing gap via monitoring.  Rather than wait for a user to report an error and asking for a log file, we get out in front of the matter.  When something flies off the rails, our monitoring tools quickly alert us, and we begin triage immediately.



Common Monitoring Use Cases


Later in this post, I will get imaginative.  In writing this, I intend to expose you to some less common monitoring ideas that you might at least contemplate, if not outright implement.  But for now, let’s consider some relative blue chip monitoring scenarios.  These will transcend even the basic nature of the application and apply equally well to web, mobile, or desktop apps.

 

Monitis offers a huge variety of monitoring services, as the name implies.  You can get your bearings about the full offering here.  This means that if you want to do it, you can probably find an offering of to do it unless you’re really out there.  Then you might want to supplement these offering with some customized functionality for your own situation.

 

But let’s say you’d just signed up for the service and wanted to test drive it.  I can think of nothing simpler than “is this thing on?”  Wherever it runs, you’d love some information about whether it runs when it should.  On top of that, you’d probably also like to know whether it dies unexpectedly and ignobly.  When your app crashes embarrassingly, you want to know about it.

 

Once you’ve buttoned up the real basics, you might start to monitor for somewhat more nuanced situations.  Does your code gobble up too many hardware resources, causing poor experience or added expense?  Does it interact with services or databases that fail or go offline?  In short, does your application wobble into sub-optimal states?

 

But what if we look beyond those basics?  Let’s explore some things you may never have contemplated monitoring about your software.



User Engagement


Facebook has developed some reputation around having deployment nirvana.  They constantly roll to production and use a sophisticated series of checks, balances, tests, and monitoring to alert them to problems needing correction.  If the number of baby pictures in my feed is any indication, I’d say they’re doing pretty well.

 

But what happens if Facebook pushes something to production with a mistake not easily caught by automated unit tests?  For instance, what if they accidentally deployed some CSS that turned the “post” button and its text the same color as the background.  The flow of baby pictures would cease, even as all tests passed with flying colors.

 

Monitis offers “real user monitoring,”  which generalizes a specific case can address this situation.  You may want to monitor user behavior in terms of how they engage with the site.  If Facebook monitors how many times per second its users click “post,” and they see that drop to 0 after a production roll, they’ll know they have an issue almost immediately.  Even if they don’t know what causes it, they can triage and mitigate almost immediately.



Revenue


If you have responsibility for any sort of e-commerce operation, I strongly encourage you to monitor your revenue.  In a sense, you might consider this a specific instance of user engagement.  You’ll have some sort of normal drip of people making purchases.  Anything affecting that presents you with an obvious red flag.

 

You might be tempted to think of this as an accounting problem more than a technical one.  Let techies monitor the nuts and bolts and accounting can worry about P&L?  I don’t advise it. Purchases count as arguably the most important metric.  They form the lifeblood of your business.



Bounces


You mainly think of a “bounce” when you think of web applications.  Google defines bounce as “a single-page session on your site.”  I believe this plays on the opposite of “sticking.”  People land, and “bounce off” of your site.

 

I’m going to re-appropriate the term a bit for our purposes here and generalize it to all application platforms.  You might want to monitor the rate at which users exit your application from a particular page/screen.

 

When they leave from, say, an “exit” screen, then fine.  You’d want a high percentage of departures from expected places.  But if people being to leave from a place you’d expect them to remain engaged, that might give you insight into a problem of some kind.  This holds doubly true if it suddenly spikes in one particular place.



User Experience Concerns 


This particular concern would require some fairly sophisticated monitoring capabilities, most likely instrumented from within.  If you do implement such a thing, take care not to impact performance.  But, if you’re up for it, you might learn some interesting things.

 

Consider monitoring user behavior for user experience concerns.  For instance, do users consistently dismiss a dialog far too quickly to have read it?  Or perhaps do they all tend to execute the same key sequences to navigate through several screens?  If so, you might have located opportunities to improve your user experience.  Get rid of superfluous dialog messages and see about adding shortcuts for things they do frequently.

 

And you certainly aren’t limited by my suggestions here.  If you have the capability to monitor interactions like this, study your own users with their particular happens and look to improve their experience.



Time to Load Visual Elements


This is another item that you hear about most frequently in websites.  But, as with my looser interpretation of the “bounce” concept, you could really measure this anywhere.  After all, sluggishness is sluggishness.

 

If you find yourself in a position to monitor the visual performance of your software, you stand to benefit from doing so.  Few things torpedo the user experience as quickly as maddeningly slow loads.  If this is happening, you want to know about it.

 

This holds doubly true for visual elements superfluous or non-essential to the experience itself. In the world of websites, think of ads or random widgets.  And, while you can test a lot of this for yourself, concerns may arise in the wild that you can’t mimic in your own shop.



Think of Your Own in the Spirit of Innovation 


I’ve enjoyed the exercise in exploring what you might want to monitor.  As both an entrepreneur and software developer, I like thinking about possible implementations, offerings, and features.

 

In fact, that captures what I find so appealing about the DevOps movement.  As we marry software creation and software delivery, we open up an entirely new category of innovation, that requires new and powerful tools.  We can then combine those tools with the inventive spirit to deliver ever-higher quality software.



Sign up for Monitis FREE 15-day full-featured trial! Premium plan starting from $12/month only!



0

Read the original post on Monitis Blog.


Hi.  My name is Erik Dietrich, and this is the first time I’ve posted on the Monitis blog.  By way of introduction, I thought it would make sense to talk about my initial experience with Monitis.

 

Before I do that, though, I need to explain a bit about myself.   Don’t worry.  It’s relevant, I promise.

 

I’m a techie by trade.  Specifically, I have historically made a living as a software developer, architect, dev manager, CIO, and, these days, IT management and strategy consultant.  On top of that, I write and present frequently, including routine publishing to my own, tech-centric blog.

 

Because of this, I know a certain tension to which you can, no doubt, relate. I’m talking about the tension between not having time to build and look after your own website and thinking, “what kind of developer am I if I don’t build and look after my own site?”  I feel awkward about it, but over the years, I’ve come to the conclusion that it’s better to leave my site’s development to WordPress and the folks that make themes for it.  I just don’t have time to take care of it myself.

 

But this delegation can lead to embarrassing lapses.  I write about software professionalism, IT strategy and the delivery of high quality solutions.  So when someone that follows me on Twitter sends a tweet informing me that my website has gone down, I can’t help but feel silly.  Anyone looking at the situation obviously knows that it’s my hosting company or, perhaps, something with WordPress.  But that doesn’t stop me from feeling the ironic sting of being the last to know about my own outage.



Mitigating Outages for Professionals


When I ran an IT department as the CIO, I had responsibility for some public facing web applications.  I understood acutely the embarrassment of an outage, and I understood how it could be mitigated.  If you become aware of it first and inform your users, you lose far less credibility in their eyes than if they find out and inform you instead.  The outage is still unfortunate for everyone, but you being on top of it makes it seem almost planned to the users that hear of it.

 

To make sure my group had this advantage, I oversaw the instrumentation of monitoring tools within our network.  This was some years ago now, so I don’t recall the particulars, but I do remember having a dashboard to peruse and getting emails and text notifications to alert me immediately of any problems.  This was powerful stuff.


  

Mitigating Outages for the Rest of Us

 

When it comes to my own blog and site, however, this sort of instrumentation never occurred to me.  I had sound reasoning.  An outage on my site is not critical to anyone.  Nobody logs in and interacts with the site in a high-touch way – it’s just content that I publish for people to read.  I don’t lose money when my site was down.

 

Because of all of these considerations, it made no sense to me to invest in monitoring.  I had a preconceived notion of the cost of such things, since I had, in the past, allocated budget for them.  Had I really gotten serious about it, I would have reasoned that I could probably do better in price a few years later and with different needs, but it never really bubbled up near the top of my own personal priority list.

 

This changed, however, when I encountered the Monitis product offering.  I’ll fast forward a bit and say that today, I have effective monitoring for my site that gives me exactly the data I want and costs me almost nothing.


  

Getting Started


I would offer a “how to” at this point, but you’ll have such an easy time it’s honestly not worth the bother.  Go to the main site, click “start monitoring now” and fill out the requested information.  That’s it.  Really.

 

I did this, and true to what they say, I had monitoring of my site set up within 3 minutes.  At the time I performed the setup, I recall being in something of a hurry, so I just kind of did a fire and forget.  I setup monitoring HTTP for my site, and didn’t think anything more of it for the rest of the day.

 

The next day, I got the email shown below.  I saw that they had hit my site with HTTP requests from 3 different locations.  Cumulative uptime of 100%, too.  I won’t lie — I was a bit relieved to see that “all good” seemed to be the default state of affairs.



For a few more days, I continued to receive this daily summary.  I had an even larger sample size of things being alright, and, about a week in, I found myself with a bit more time to dig into the monitoring itself.  I logged into my newly-created Monitis account and poked around in my dashboard.

 

The default monitoring that I had setup involved 3 locations making HTTP requests all day to my site.  If any 2 locations failed simultaneously, I would receive an email alert that my site was down.  At the time, I had signed up for a trial account, so my next bit of curiosity was “what will this cost me.”  When I went to the pricing page and punched up what this would cost on an ongoing basis, I found the result quite reasonable: $1.20 per month.

 

Wow.


 

My Takeaway: The Value Proposition

 

I could kick myself for not doing research earlier. I keep my finger on the pulse of many different trends and technologies.  And, if you would have asked me whether or not some kind of affordable site monitoring technology existed, I imagine I would have said, “gosh, probably.”

And yet, I never went out and did the research.

 

The obvious lesson here is that affordable and effective monitoring for your site exists.  Even if your site is simply you posting a food recipe or two per month, and a couple of your relatives reading it every now and then, it’s probably worth about a dollar per month to make sure it runs smoothly.  Call it peace of mind or call it professional pride.  Either way, if you have a site, you might as well keep an automated eye on it.

 

But the deeper lesson here is one of cost and specialization.  Cloud technology and its ramifications extend beyond, “it’s easy to provision a server.”  All facets of traditional IT are becoming commoditized and offered affordably and with good quality to people with budgets of all sizes.  If it’s been achievable for the enterprise for years, keep your eyes open, because, quite probably, a version is achievable for you as well.



Sign up for Monitis FREE 15-day full-featured trial! Premium plan starting from $12/month only! 



0

Originally, this post was published on Monitis Blog, you can check it here.


Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, could lead to some difficult decisions about what to cut.

 

Web loads speeds are integral factors in determining your SEO and how long customers will stay at your site. But web design, as important as it is for driving traffic, can also get in the way of your ultimate goal of bringing customers and revenue. In other words, you must avoid page bloat at all costs!

 

This is why businesses today, more than ever, must develop a clearly defined web performance optimization strategy. In fact, web monitoring should be an integral part of your web design best practices. To be clear, web performance optimization (or WPO) is the science of making your website perform better so it increases visitor retention, improves SEO, and drives more sales.


To give a great case study of how WPO works, consider what 37signals (now Basecamp) did with their Highrise marketing website. Using A/B testing, the company did multiple tests to determine the best plan for their landing page. In one case, the original background was white and cluttered with information. A dramatic change was made by replacing this white background with a picture of a person smiling.

 

The new landing page led to an increase in signups at the Highrise site by 102.5%!

 

This list provides another 99 great case studies of how WPO made a huge difference in website conversions.

 

In what follows, we take things further by providing you a brief checklist of the key steps to ensuring your website performance optimization strategy is on track.



Keep Things Fast! 

Website conversions are integrally tied to the speed of the site. One second saved in download time can make all the difference between a sale or a bounce.


  

Check Your Web Hosting 

Your web hosting may offer “unlimited bandwidth” but if it involves shared services with other websites that impacts overall performance, then is it really worth it? It’s always a good idea to periodically review your hosting plan to ensure you’re getting the best value for your dollar.

  


Make Your Site Mobile First

Having a “mobile first” website is critical to success in today’s digital marketplace. If you don’t believe it, just consider that mobile commerce transactions in the United States alone are expected to total $123 billion in 2016

  


Image Optimization 

“Page bloat” – or the practice of cramming websites with high density images – has gotten out of hand and is the number one culprit for long page loading times. Don’t bloat your website! One of the best ways to ensure proper image optimization is to adopt correct sizing and formatting for all your images.

  


Go Easy with Affiliate Codes & Ads  

Ads and affiliate code are good . . . up to a point! But when you go overboard, this can lead to high bounce rates and can adversely impact your overall website performance. Constantly check how third-party applications impact your load speed! 

 


Cache Often 

Caching is a mechanism for the temporary storage of web pages in order to reduce bandwidth and improve performance. This saves server time and makes your website faster overall.

  


Use a CDN 

Content Delivery Networks deliver the static files of a website, like CSS, images, and JavaScript, through servers that are in closer proximity to the user’s physical location. Every second that you save in download time is dollars in your pocket.

  


Make Your CTA Front & Center 

Don’t make your landing page a game of “guess where to check-out the merchandise.” Visitors don’t want to spend extra time trying to figure out where to complete their transactions. Your Call to Action should be front and center on the landing page.



Adopt Cloud-based Website Monitoring 

Imagine having all of the vital statistics for your website in a nice convenient dashboard, and getting alerts about trouble spots long before they reach impact your customers. Cloud hosted web monitoring is the crucial component in today’s digital marketplace. IT system monitoring is first of all a real time data that can help you respond to problems. You cannot do without monitoring tools, if you hope to optimize and maximize your application’s performance.



Sign up for Monitis FREE 15-day full-featured trial! Premium plan starting from $12/month only! 

1
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives basic information about SQL injections
4
Login Failure
It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
1
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a few months or a few weeks to get market trend inform.
0
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
0
Get 15 Days FREE Full-Featured Trial
LVL 1
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Transparent Cloud
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and disk performance.
0
 
LVL 2

Author Comment

by:Superb Internet Corporation
Comment Utility
Understood. Thanks for the help. Do you need me to rewrite it? Let me know.
0
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
0
A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers for re-developing a maintained code. With this technology, a local and web copy of projects can be saved. 

How Does Version Control System Works?

A Version Control System simply allows saving multiple snapshots of single project. Say, we have a project and files of code. When we work on it for some time, we might find the need to create a safe point of it (which is S1 in the figure).

Now, if we want to work more on the same project, we can copy the code and modify it and then again create its safe point (which is S2 in the figure). And likewise, it is possible to continue modifying the project (S3) but at the same time maintain history of previous projects as well. Say, at some point of time, our project did not work well (S4). So, we have the option to go back to the previous version (S3) and get started again.

When a Git repository is created, a master branch is developed and as long as we generate safe points, the master branches are added. Now, there can be requirement of adding new features to a project that is working currently (S4). So, when one developer is busy adding features to the project (F1), another can continue to make relevant modifications and work on it (S5) and same …
10
 
LVL 2

Author Comment

by:Sofía Tomas
Comment Utility
Dear Moderator,

My article "Bitbucket vs. GitHub: Which is Right for You?" is ready for re-review. Please Check it.

Regards
0
 
LVL 2

Author Comment

by:Sofía Tomas
Comment Utility
Dear Editor,

Thanks for your reply.

Regards
0

What is Node.js?

Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event driven, which throws a whole new light on the way a server side app performs. As Node.js is the complete package (web HTTP server and server side language), there is dramatically less overhead in implementing it as a webserver when compared with a typical Apache (and PHP) or IIS (with ASP/PHP) installation.

Node.js is written in JavaScript, the most common client-side language around. This reduces the learning curve somewhat for most web developers as they understand JavaScript and how to code it.
 

Why is it Important and what are the Benefits?

Most of the server side languages I’ve used are built on sequential execution models, meaning one task has to finish before another one begins. For instance, PHP (in conjunction with the type of server it is running off e.g. Apache) will spawn a thread for each request made to the server. If that thread needs to get data from a database that takes a while or another request comes in, that thread is locked up and consuming resources. For a data intensive app with many concurrent connections, that could severly impede the server’s performance.

Node.js is single threaded (yes only one thread!) and is beneficial in applications where frequent blocking I/O requests
9
Introduction
A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely principles, like "an apple a day keeps the doctor away." But they serve to guide us in the right direction as we design and build our systems.

There are no real "shortcuts" here.  As Euclid said to Ptolemy, who wanted to know the easy way to learn geometry, "There is no royal road to geometry."  So, too, there is no royal road to good object-oriented design. But that said, read on for some of the summary and background information that will make your software designs more coherent and easier to build, test, extend and reuse.

Do I Really Have to Learn This?
What happens when these principles are ignored?  Some call it software "rot."  I prefer to think of it in terms of fragility and viscosity.  Software that is of fragile design is difficult to extend or modify.  Even simple changes can induce seemingly unrelated entropy elsewhere in the system (Einstein called this, "spooky action at a distance").  Eventually this phenomenon comes to the attention of the business managers, and they become resistant to change.  Developers become frustrated as micromanagement ensues.  Ultimately the system must be scrapped and re-invented.

Software that is viscous
6
 
LVL 110

Author Comment

by:Ray Paseur
Comment Utility
Thank you, Todd.  As time permits I will have five more articles in the series to illustrate each of the principles at work in PHP.
0
Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I have seen several downtimes during the holiday season and promotional events, which is catastrophic for businesses.

The reason for this is mostly performance bottlenecks or scalability issues. Usually web applications get their data from relational databases. If an application is not designed right, databases become bottlenecks. The cost of scaling an enterprise databases like Oracle or DB2 is huge and can take us only so far as most of the relational databases are not always horizontally scalable. The other bottleneck is usually web service calls. On high loads web service calls can literally kill a website not designed for scalability and performance.

I recommend the use of caching for almost any application. Though I have used memcached and EHCache as caching providers and will be using memcached's example for this article, I am not here to propose any one caching solution. For simple websites simple map based solution of WhirlyCache, OSCache or cache4j might work pretty well, though you can still use more advance solutions like EHCache, memcached, JCS, Terracotta, Oracle Coherence
4
 
LVL 14

Expert Comment

by:ThG
Comment Utility
I think I miss some point here, if you store it as "currentCustomer" and you have 2 clients currently browsing your website what happens when customer B makes a request? He will appear as customer A due to the shared "currentCustomer" cache key.

I agree session-scoped caches are bad but I think your cache-key should be something like "currentCustomer-<id>" then the session cookie should provide <id> and <auth_nonce> and then you can retrieve from memcache currentCustomer-<id> and verify that the auth_nonce matches, or something like that.

I really don't see how the proposed solution could work in a multi user environement.
0
 
LVL 5

Author Comment

by:gksinghiet
Comment Utility
Hi ThG,

Good catch!!! I will fix it in the article. To keep is simple and focused on caching only, I will not talk about nonce here.

Thanks for your feedback.
0
Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again trying to fix the issue. In this walk through I will cover few most helpful tools available. I am using Chrome and a sample ASP.NET MVC application
 
To open the developer tool you have following options:
  1. Keyboard short cuts – Cntrl + Shift + I/J/C or simply press F12
  2. Right click on page – Inspect element

Chrome's developer tool looks like
1.pngThe top menu has several option to enable you focus on specific page information.2.pngElement
This is to inspect/modify page's DOM tree (HTML and CSS). You can modify HTML and styles here and see the change without the need to reload the page. The modifications do not effect your source files; the changes are local to your browser. Refresh/reload will undo changes made on the browser.

To view HTML DOM
Right click on the element and select the one you want to inspect or click on the magnifying glass on top left, and then move the mouse over the element you want to inspect. When you inspect any element you will see this:
3.pngThe left panel shows the DOM and the right panel the CSS Style of selected element. By default the HTML of other elements are collapsed; to open/collapse them click on the black triangles.
4.pngTo Modify Element
2
If I have to fix slow responding website my first thoughts are server side optimizations: the database may not be optimized or caching is not enabled, or things like that. We often overlook another major part of our web application: the client. We often ignore this area, but it has major impact on performance of a website. So before jumping into optimization we need to know how things are processed by the browser.

Web pages utilize a lot of resources; they can contain images, JavaScript and CSS files, Flash and much more. For each individual resource there is a separate request from the browser to the server -- and requests cost time. Each request has two phases, the time required making connection to the server and making the request, and the actual time it takes to send the resource and download it to the broswer.

Each additional image or file is slowing is your website. Browsers should download these resources in parallel, but there is limit to how many concurrent connections a browser can make to your website at a given time. The typical modern browser can have six to eight connections to a domain. This means that no more than eight parallel request will be made to your website by browser. If your page needs more resources, the browser will have to wait for previous requests to be completed before it makes the requests for other resource; until then, they are queued and compete for connections to the server. Moreover some resources depend on other resources -- for …
1
Foolproof security solutions has become one of the key necessities of every e-commerce or Internet banking website. If you too own an online shopping site then its vital for you to equip your web portal with customer security features that can allow your visitors to experience optimal security while undertaking a range of monetary transactions. SSL(Secure Socket Layer) is one of the most promising security options for websites that include sensitive data. In this article, you'll find everything about SSL and its significance for a website that's powered by ASP.NET.
 
What is SSL exactly?
SSL (Secure Socket Layer) is a highly commendable security mechanism that's being used for encoding communications between the client and server. This is specially helpful for websites which involve a lot of financial transactions. By sending the data between browser and web server in an encrypted form, SSL prevents any sort of tampering by unauthorized individuals such as hackers. SSL works as an excellent tool for securing the privacy of sensitive data, keeping it confidential to the fullest. SSL works perfect for hiding sensitive data including bank account details, login information, credit card details etc.
 
SSL Certificates - What are they?
SSL certificates basically contain the organization/website's digital identity that includes symmetric as well as asymmetric keys. As a website administrator, you …
0
Three Considerations for Containers
LVL 2
Three Considerations for Containers

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read our article on Experts Exchange.

New Relic:

Our company recently started researching several products to figure out what were the best ways for us to increase our web page speed and to quickly identify performance problems that we may be having. One of the products we evaluated was New Relic.  Here is a list of pros and cons that my team came up with that may help you decide of New Relic is right for you.


Pros:


1) Application Stack Trace Details

New Relic offers a great interface for debugging the server side of performance issues. While running on your servers it keeps track of the entire run time stack and gives a detailed report on issues. For example, it counts up the number of database queries that are running within your particular thread and gives a report on how many different queries are executed and how long each took. This is a great feature to allow you quickly to identify performance issues: which queries take too long, which query is called too many times, what function is running for way too long.  All these issues become apparent for you to fix.
 

2) Global Real User Tracking

Since the application runs on your servers and also as part of javascript on your webpage, you get accurate real user page load times. This was way more valuable to our company than simulated traffic because it allowed us to see exactly how our web pages were performing all across the world. Real user page performance tracking …
1
Using Quotation Marks in PHP
This question seems to come up a lot for developers who are new to PHP.  And it got me thinking, "How can we explain the rules for quotation marks?"  For better or worse, PHP has so many rules!  This article tries to answer the questions.

First, some mandatory reading.  You need to understand the terms "variable" and "string" as they are used in the context of computer programming.  Take a moment to read these pages.  If it doesn't all "click" at first, don't be too concerned.  We will show some examples and explanation below.
http://php.net/manual/en/language.variables.basics.php
http://php.net/manual/en/language.types.string.php
http://php.net/manual/en/language.operators.string.php

Quotation Marks Used With Strings
A string is nothing more than a few characters strung together.  The code snippet below has examples of perfectly valid strings.  The first string is the single capital letter "A" and it has a length of one character.  The second string is the empty string.  It has a length of zero.  You can probably figure out the lengths of the other two strings.
A

Alphabet Soup
@@@

Open in new window


If you want to assign these literal string values to PHP variables, you must put quotes around them in the assignment statement.  Both of these examples are acceptable.  Note that one uses single quotes and the other uses double quotes.

$x = 'Alphabet Soup';
$y = "Alphabet Soup";

Open in new window

8
A Change in PHP Behavior with Session Write Short Circuit (Winter 2014)**
With the release of PHP 5.6 the session handler changed in a way that many think should be considered a bug.  See the note at the end of this article.

A Foreword: PHP session_unregister() (Fall 2014)
Some obsolete code sets contain "Logout" examples that use the session_unregister() function.  PHP deprecated this function more than 5 years ago and removed it recently.  If you have a script that uses session_unregister(), you should replace the function name with unset(), using the same function call arguments.  Going forward, do not use session_unregister(), session_register(), or session_is_registered().  Instead check the PHP man pages for these functions.  There are solutions and explanations of the alternatives in the user-contributed notes.

And now, on to our Article: PHP Sessions -- Simpler Than You Think
This EE question ("I am looking for a solution for logout after inactivity.") got me thinking...
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28169149.html#a39280833

Developers who are new to PHP session handling sometimes over-think the role and behavior of PHP sessions.  This article takes the process apart and reconstructs it to show how easy it can be to use the PHP session to your (and your clients') advantage.

Use the Built-In Features Whenever Possible
PHP already has a built-in solution
10
 
LVL 110

Author Comment

by:Ray Paseur
Comment Utility
Gladly, Keith :-)  What topics would you like to cover?
0
 
LVL 5

Expert Comment

by:Jim Riddles
Comment Utility
The same goes for me.  I have learned so much about the proper way to approach PHP programming.  I still have so much more to learn, but with Ray's articles, I know that I will get there.  Thanks so much, Ray for all of your time and efforts!  They are much appreciated.
0

Foreword (May 2015)

This web page has appeared at Google.  It's definitely worth considering!

https://www.google.com/about/careers/students/guide-to-technical-development.html


How to Know You are Making a Difference at EE

In August, 2013, one of my colleagues posted this, and it made my heart glad.

Grading Comment:
Thanks so much Ray!  I actually haven't posted in a while because at your suggestion I got a few books and spent the last couple of months reading and learning and it's made a world of difference, so thanks a ton for that suggestion as well!

"And by the way,... I am New to PHP"

So many PHP questions at Experts-Exchange include (or should include) that statement that it got me thinking about how to advise new programmers on ways to begin learning PHP.  The popularity of PHP is undeniable; it powers an overwhelming number of web sites, from the very smallest to the giants like Facebook, hundreds of thousands of WordPress blogs, and everything in between.  So it makes sense that any web developer would need to have some foundation in the PHP language.  And for many novice programmers, PHP is the first language they try to learn.


PHP came from humble beginnings; it was originally captioned "Personal Home Page" and was intended to be a language so easy to use, that "even Grandma could learn to use PHP."  And that was fine in the 1990's before the advent of object-oriented programming, hackers, spam, and web services.  But the online environment has grown up and PHP has been forced to grow up, too.  Today, while PHP can still perform simple tasks, PHP can also power enormous database-driven applications that build online communities and analyze mountains of information.


My favorite description of PHP, disarming in its elegance and simplicity, is "What PHP can do is convert a static website that has content that has to be changed by hand into a dynamic one that can display content based on any criteria you can think of."


Getting started with PHP can be daunting, especially if you do not have a background in computer science.  This article will give you some learning resources to get the background you need and will introduce several popular and effective ways to learn PHP.  But there is something you might want to read before you finish this article.  Every professional programmer I know thinks that this is an article of wisdom.  You can take it in if you have seven minutes.  Then come back and finish this article.


Getting the Right Foundation

If you really want to be a professional programmer, you probably want to go to college to major in computer science or electrical engineering.  Almost every major college and university teaches these subject, and the principles are not very hard to learn, but it takes time and practice to turn the learned principles into praxis.  Even if you're not sure about making a career in programming, if you're read this far you probably want to consider taking an Introduction to Computer Science class.  Fortunately, these classes are now available online, for free, using the same syllabus, curriculum and learning materials that the colleges use.  


As but one example, here is what M.I.T. offers:

http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00sc-introduction-to-computer-science-and-programming-spring-2011/Syllabus/


If you're serious about learning programming, you will need a little math (but not very much).  This series of video lectures will give you a good foundation.

http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-042j-mathematics-for-computer-science-fall-2010/video-lectures/


Learning to Think Like a Programmer

For a variety of reasons, you're unlikely to find a basic computer science class that teaches PHP.  PHP is "easy" and these classes are for scientists who like things hard (I'm only joking a little bit).  Expect to find C, Python, Java, JavaScript and similar highly structured programming languages in the beginning classes.  Don't worry about that -- every programmer who achieves anything noteworthy has written programs in many different languages.  The ideas from one language or another bring about a level of intellectual cross-pollination that helps you think about problems from different perspectives and map problems onto different computational frameworks.  And at the most basic levels, all programming languages share many common aspects.  The greatest difference is the written syntax we use to express our ideas.


Do Not Waste Time on Non-Working Code

A programming language is a tool that builds a sequence of instructions.  The instructions tell the computer what we want it to do.  For almost everything you might do with PHP, the thing we want the computer to do is manipulate data.  Each programming problem can be defined and understood in terms of an input and an output, with the computer programming being the intermediary that transforms the input into the output.  If you think about that for a little while, you will come to the same conclusion that almost every experienced programmer comes to: it does nobody any good to post code that does not work.  Instead define and post the data and you will be amazed how quickly you can find clear, easy-to-understand answers.


Expect to Spend a Lot of Time Debugging

You will find that you're human and the computer is not.  Problems expressed in human languages are turned into solutions expressed in computer languages.  This process is full of ambiguity, double-meanings, and confusion.  Humans share culture, but computers require precision at a sub-microscopic level.  Even a single character out of place can render a computer program useless (or worse, destructive).  It's very rare that a programmer can write more than a few lines of code without introducing an unwanted element.  The process of correcting and removing these unwanted elements is called "debugging" and until you have several years of programming experience, it will consume most of the time you spend programming.  More about programming and human factors, as well as many interesting observations from the trenches is available in Jeff Atwood's writings.


Deconstruct Problems Until They Are Small Enough to Solve at a Glance

Complex programs are made up of simpler programs, and simpler programs are made up of even simpler programs.  A mental process of deconstructing problems underlies all programming activities.  As you learn PHP, you will find that you deconstruct complex problems into several smaller problems that are readily solved using PHP programming solutions.


You may have heard of the phrase, "Hello World."  It is the name given to the simplest example of the solution to any programming problem, and it demonstrates success in some small aspect of building a more complex program.  In PHP, the "Hello World" exercise looks something like this.


 

<?php echo "Hello World.";

This simple PHP script proves that PHP is installed correctly and that it can produce output that is visible on a web browser.  More importantly, it removes many elements of confusion and ambiguity.  What if this script did not work?  Where would you look for a solution?  What symptoms of failure could you find?  Who can help?  All of these uncertainties and doubts impinge on the process of debugging.  And thus we come to the first and most important part of thinking like a programmer: Make the larger problems smaller by reducing each of the larger problems to a collection of smaller problems.


Do this iteratively until the smaller problems are so small that the solution is obvious.  The small solutions then become the building blocks of the larger solutions.  As you construct larger solutions from smaller building blocks, you will hide the details so that the result works like a vending machine - providing useful services to many clients (either programs or people).  Programmers often refer to such self-contained units as a "black box."


Learning the Language of Programmers

A shared culture has a shared language and many terms of art.  You can learn something of PHP without knowing much about general purpose programming, but your learning will be faster and easier if you understand the language that programmers use.  Many familiar words assume new meanings.  For example, the word class takes on a unique meaning when it's applied in the context of computer programming.


I am not suggesting that you need to read or memorize every term of art (a professional will) but you need some good references that you can use to look up words that are unfamiliar or are used in unfamiliar ways.  You might want to take an afternoon to browse these glossaries.


LabAutopedia

Henson's Glossary

Cal State CS202

WhatIs.com TechTarget Programming Words


Learning the Techniques of Programmers

All good programmers have been forced at one time or another to research a subject that they know nothing about.  They have to find out numerous details (too many to remember) and develop code that handles these details.  It's a huge exercise in short-term memory, and it's a huge investment of time.  You wouldn't want to have to do it over again.


Unfortunately, some programmers are condemned to do it over and over again because they didn't write the code clearly, or they used thoughtless variable names, or they left out the comments.  And when they need to reuse that piece of code, they find themselves looking at it and wondering things like, "Did I test this enough?" or worse, "What was I thinking?"  You can avoid this problem by following a few simple rules.


Before you begin writing code, learn the "PSR" basics.  These are valuable standards.  They will make your programming easy to read and understand, and they will make your code look professional (highly valuable if you want to get a job as a programmer).  Here are the two links you should study.

http://www.php-fig.org/psr/psr-1/

http://www.php-fig.org/psr/psr-2/


1. Whenever you're required to solve a problem that you have never solved before, make a teaching example from the solution.  Collect a library of these.

2. Whenever possible use meaningful variable names, eg, if the value is "Today's date" name the variable $today instead of something useless like $x.

3. Use comments to say what your programming is intended to do.  Often you will find that simply writing the commentsfirst, before you write a single line of code, will help you consolidate your thinking.

4. Test iteratively as you build the code.  Don't write more than a few lines without testing.  Use the principles of Test-Driven Development.

5. Programming is all about the data.  Learn about var_dump() and make regular use of it!

6. Avoid copying code you find on the internet, especially code that has a lot of compound statements.  Instead of copying, deconstruct the code, taking a moment to ask, "why?" and rewriting the code in your own words, with your own explanatory comments.

7. Adopt a coding standard and adhere to it rigidly.  With discipline comes great power.


Learning How to Get Help: the SSCCE

Anyone who says he is a self-taught programmer is missing something.  You cannot make this stuff up - you have to learn it from a variety of sources, and one of the most important sources is the community of programmers who surround you.  Perhaps you're in a university class where you can learn from your colleagues and classmates.  Or perhaps you're a regular at Experts-Exchange and Stack Overflow.  In any learning community you need to know how to share ideas with others.  That's where the SSCCE comes in.  If the only thing you take away from this article is the SSCCE, it will have been worth my time to write it and worth your time to read it.  Follow the link, read the page (there is only one page) and embrace the principles!  The SSCCE is not alone in the universe, other authors have given voice to the same concept: a problem well stated is a problem half solved.


Think about the data - what do you have for input and what do you want for output.  Try to assemble that information before you ask the question.  Then you can say, "Here's what I've got and here's what I want."  That makes for a clear problem definition.  Clear problem definitions will save you an amazing amount of time.  As Charles Kettering said, "A problem well stated is a problem half solved."


Try to avoid complicating the situation with an unnecessary explanation, when an input/output example could be used instead.  This is an actual quote from a question posted here at EE: "take that number, split it into an array. so 25 would become [2,5], or 12 would become [1,2] then use those to determine which image to show in the basket count, then loop the array to determine which images to show"  What's the author trying to say?  Your guess is as good as mine.


Learning PHP from PHP.net

Now that we have introduced the deep background stuff, and shown you how to frame a problem and ask for help, it's time to get into the part of this article that is about learning -- and using -- PHP.


A good place to start is with php.net, where you will find the best online technical documentation in the world.


If you do not read the online documentation, you're robbing yourself, stealing valuable time from learning.  Instead of learning from the experience and writings of others, you'll be learning by trial and error, maybe from reading other people's programs.  That takes longer.  A lot longer.  And it's full of risk.  Trying to learn programming by trial and error is like trying to learn to bake by looking at an apple pie.  Sure you can appreciate the finished product, but looking at a pie will tell you nothing of the other ingredients, the processes and the tools used to make the pie.  Likewise, a finished program tells you nothing of the thought processes of the developers, nor of the assumptions they made or the test data they used.  So don't try to learn that way.  Instead, exploit the php.net web site for all its worth.  Here is how.


New in 2014: PHP has an About the Manual page, including How to Read a Function Definition and links to Support for New Users.


PHP has a "getting started" page.

PHP has an introductory tutorial.  No excuses -- Just Do It!

PHP has an omnibus FAQ page.

PHP has its entire manual online!


PHP has its own Security page and it is required reading, no excuses!


PHP has the language reference online.   No excuses here either.  You must read these sections and every one of the associated links:

Basic Syntax

Types

Variables

Constants

Expressions

Operators

Control Structures

Functions

Predefined Variables


If you want to move beyond basic PHP programming and begin collaboration with others, you want to read these sections, too.

Classes and Objects

Exceptions

References


If you want to interact with software or data on other servers you need to read these sections.

Context Options

Protocols and Wrappers


If you want to learn from the collective wisdom of others, these FAQ pages are very helpful:

Using PHP

PHP and HTML

PHP and Databases


Part of what makes php.net so valuable is the function reference.  PHP has, at this writing, over 1,500 built-in functions.  You can't memorize all of them, so you need a quick way to refer to them.  When I am programming I have a window open to php.net at all times.  If you know the name of the function you want to use, just type a URL like this: http://php.net/date and PHP will find the date() function.  Couldn't be easier!  And the magic doesn't end with the official PHP documentation.  Every function page has a section for user-contributed notes.  Often, seeing the way others have used a function (or learned from an unpleasant surprise) will give you great insights into the richness and power of the PHP language.  For example, see this:

http://php.net/manual/en/function.array-slice.php#112359


If you don't know the name of the function you want to use, you can find the function reference table of contents.   Don't plan on reading all of this.  You might want to bookmark it.


The parts of the function reference that you want to read first are probably these:

Date/Time

Database, especially MySQL

File System

Strings

Arrays

Variables

Sessions

SimpleXML

JSON


Learning PHP from Books

One of the really great things about tech people is that they like tech features, for example, the ability to write book reviews on Amazon.com. If you find a popular and well-reviewed book (and it's not too old) it will probably make a valuable addition to your technical/professional library.  You can't have too many PHP books!  Here are some of the books that I own and recommend.  If you decide to get any of these, be sure to look for the latest editions, because PHP is a living language.


Beginner: Yank Ignore the hokey title -- it's a good book.

Beginner to intermediate: Welling/Thompson

Intermediate to Advanced: Powers

Intermediate to Advanced: Ullman

Advanced: Zandstra


Learning PHP from Online Resources

Most of these resources are 100% free:  Almost anything about PHP from SitePoint is worthwhile.  There are good introductory references at Tizag and W3Schools, however the Tizag PHP web site appears to have gone out of date.  Many of my students swear by CodeAcademy.  And of course there is a Wiki: http://en.wikibooks.org/wiki/PHP_Programming


New in 2017: Stefan Priebsch curates this site on Software Craftsmanship (advanced)

https://php-craftsmanship.info/


New in 2016: Jeffrey Way brings his considerable teaching skills to a set of PHP courses here:

https://laracasts.com/series/php-for-beginners


While you are mastering the basics of PHP you will have many questions that others have had before you.  This is a worthwhile resource for many of those questions.

https://phpbestpractices.org/


Once you have mastered the basics of PHP, there is an excellent online resource from the authors of the Slim Framework.

http://www.phptherightway.com/


A set of paid courses on PHP is available from lynda.com.  It is not clear to me whether these are up-to-date.


A set of paid courses on PHP, from active PHP experts, is available from PHP Architect.  The company also publishes books and newsletters, and runs conferences covering PHP topics from the most introductory "bootcamp" to advanced object-oriented design.  If you want to learn from the best in the business, this is the place to come.


Learning PHP from "That Guy" -- NOT!

You've heard the expression, "Don't be that guy."  I'm going to add a recommendation here: "Don't learn PHP from 'That Guy'."  The internet is littered with examples of terrible PHP code.  Mostly it's code from half-taught programmers who don't understand the principles of computer science, don't understand the principles of programming security and don't take the time to clean up after themselves.  It turns up in forums all the time.  It may be untested.  It's almost always undocumented.  And it's something you would use at your own peril.  It's usually worth exactly what you paid for it!  So just say "no" to that stuff and stick to the links published here.  It will save you a lot of grief.


Summary

Don't feel awkward or embarrassed if you're new to PHP.  Ignorance is no sin and we were all new to the language once.  Instead, embrace the learning resources documented here, build your own personal library of code examples, post plenty of PHP questions at Experts-Exchange and most importantly give yourself time to work with the language, so that you become familiar with the commonly used parts.  The gift of time and study is one that only you can give yourself, and it may be the most valuable gift of all. And if you're doing it right, learning PHP is fun.


Welcome to PHP!


Please give us your feedback!

If you found this article helpful, please click the "thumb's up" button below. Doing so lets the E-E community know what is valuable for E-E members and helps provide direction for future articles.  If you have questions or comments, please add them.  Thanks!

 

30
 
LVL 83

Expert Comment

by:Dave Baldwin
Comment Utility
Another thing that I have had to almost beat into some people's heads is that you can't 'logically' figure these things out.  While computers at the lowest levels operate logically, the things that people actually deal with like programming or even just using a program are based on the Choices made by someone somewhere.  You can't logically out-guess the choices made by someone else, you need to look them up in the documentation and find the rules that apply.  

The PHP developers are constantly trying to make function calls as uniform and predictable as they can... but there are a lot of things that have slipped in over the years.  And another truckload of things that are simply non-obvious.  Even those of us who write PHP code virtually every day have to do that.  People pay me to fix and modify other people's PHP code.  Like Ray, I have a browser window open to php.net almost all the time.
1
 
LVL 110

Author Comment

by:Ray Paseur
Comment Utility
@DaveBaldwin: Yes, that is the way!  Just look at an apple pie and see if it can tell you how to bake an apple pie.  It's the same with any recipe and the same with computer code.  There is not always a light unto my feet and a path before me unless I care for the details along  the way.
0
Introduction
HyperText Transfer Protocol or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to the WWW in the days after 2005 (and therefore after the advent of jQuery), that seem to evince a misunderstanding of the way the HTTP protocol works.  Since HTTP is the basic building block of web sites and web applications, a clear understanding of the protocol is required to understand how web sites really work.  And perhaps more importantly, it is necessary to understand the protocol so you can build a web site that works like another site you've seen and appreciated.  This article is intended to lift the cloud of confusion that has appeared in the years since the arrival of jQuery, CSS3, animation in web sites, and the phenomenon called Web 2.0.

The confusion has arisen in large measure because of the design movement of web interactivity away from the static page loads and into design paradigms that more closely mimic native applications.  If the hyperlink was the design element that launched the internet revolution, the event handler may be thought of as the design element that has most refined the client experience.  In all cases, at the foundation is the HTTP protocol.

HTTP is a Stateless Client/Server Protocol
Client/Server protocols are two-way communication mechanisms that allow humans to get information from web sites
18
 
LVL 15

Expert Comment

by:ericpete
Comment Utility
Ray,

A typically outstanding article. I've been fumbling through telling people this stuff for a long time, so it's nice to have a clear resource to which to send them.

Thanks!

ep
0

Introduction (All good things must come to an end)mysql_warning.pngThe original MySQL API has gone away.  It was deprecated (years ago) by PHP in Version 5.5, and removed from PHP in all current releases.  As a result, the issue is upon us today.  It's time to remediate our old PHP scripts, and bring them up-to-date for the current millennium. This article explains the issues and gives step-by-step and line-by-line instructions that can lead us out of the MySQL darkness and into current best practices.


WHY in the World Did PHP Do This?

Great question!  The MySQL extension was by far the most popular data base extension used by PHP web sites.  It had good documentation and support (consider phpMyAdmin, and after you've used that, go over to phpPgAdmin and compare features).  MySQL was thoroughly debugged, and was widely accessible - you could find literally thousands of examples of PHP+MySQL code with a Google search.  So why did PHP take such a draconian step?  In my opinion, it comes down to two issues.  


First, PHP has "grown up" as a programming language.  At one time, its proponents were looked down upon as script kiddies by the computer science community.  Never mind the fact that parts of Google, much of Yahoo, and nearly all of Facebook, Digg, Wikipedia, WordPress, and Slack are PHP machines -- there was a stench is created by the millions of incompetently written PHP web sites that crashed and got hacked all the time.  It's very easy to pick up a little knowledge about PHP and MySQL, and an unfortunate corollary is that it's very easy to use PHP and MySQL wrong!  Security holes abound, and the unsophisticated programmer propagates these errors by copying PHP code without understanding the dangers.  So in an effort to bring some rigor and science to the creation of PHP scripts, we got this explanation from P. Olson.  As you might imagine, there was early controversy over the change, but that is in the past now.


Second, the PHP authors were actually right -- the MySQL extension was simply terrible about security.  If it had been any good, there wouldn't have been a need for two million MySQL security articles!  There was nothing inherently wrong in the extension; the trouble came from the way novice programmers misused the extension.  As but one example, consider the use of external data in MySQL queries.  A common-sense implementation would have prevented the use of a query variable that had not been escaped.  But the original implementation of the MySQL extension imposed no such requirement, and the resulting security holes caused many web sites to fail. 


PHP tried to discourage the use of the MySQL extension at PHP 5.0 by removing the MySQL extension from the standard installation.  But that did not have the desired effect of luring programmers away from the dangerous and sloppy code, and that was done more than 10 years ago.  So a bigger stick was needed. The only way to make such a sweeping change in the behavior of a language interpreter (and a huge population of users) was to remove the dangerous parts of PHP and force programmers to stop using them.


In addition to security, there are many good reasons to adopt object-oriented programming techniques.  The MySQL extension by its very nature, frustrated this effort.  The MySQL API was procedural, leading to code that was messy, difficult to maintain and impossible to reuse.  In contrast, the MySQLi and PDO extensions offer object-oriented interfaces.


What are Others Saying and Doing About This Change?

On April 7, 2014, the Make WordPress team issued this announcement:

In WordPress 3.9, we added an extra layer to WPDB, causing it to switch to using the mysqli PHP library, when using PHP 5.5 or higher.  For plugin developers, this means that you absolutely shouldn’t be using PHP's mysql_*() functions any more - you can use the equivalent WPDB functions instead.


OK, What Should I Do?

First, adopt a coding standard that prohibits further use of the MySQL extension.  After today, you must never write mysql_query() again! Next, learn about the alternatives to MySQL.  Basically, you've got two good choices: MySQLi or PHP Data Objects ("PDO").


Second, be aware of the environmental changes that accompany this PHP change.  Installation libraries are different now.  The way you install the MySQL extensions is different now.  Please take a moment to read this page, especially if you're moving from an obsolete PHP 5.3 installation to a current release or version!

https://dev.mysql.com/downloads/connector/php-mysqlnd/


Do I Have to Change my PHP Programs?

Yes.  And the rest of this article shows annotated code examples to help you understand how to accomplish the changes.  The scripts have been set up as teaching examples.  You should be able to add your own MySQL credentials and install them on your own servers.  Then you can run them to see how the scripts work and how the output from error messages differs.


The scripts are shown in complete form at the bottom of the article.  In the annotated parts, only the essential pieces are shown to illustrate the different approaches.  


In each code set, the first example is the familiar-but-obsolete MySQL extension.  Following that, we have the MySQLi extension.  In that example, I tried to aim for the most direct one-to-one replacement of existing MySQL programming.  Of necessity this meant avoiding MySQLi prepared statements.  They are introduced in the PDO example, and a complete MySQLi example showing the use of prepared statements is included with the code snippets at the end of the article.  There are some differences in the syntax but for the most part the functionality lines up 1:1 between MySQL and MySQLi.  That cannot be said for PDO, where some substantial programming changes come into play.


MySQLi or PDO?

Which extensions should you choose?  Either will work.  Object-oriented MySQLi requires the smallest number of code changes.  PDO holds out the promise that you could, theoretically, change out the underlying data base without having to change your PHP scripts.  I don't know any professional programmer who believes such a claim, given the variations in SQL.  And PDO can only give you parameter binding if you use prepared statements, thus introducing a good bit of overhead.  Your choice will largely depend on the amount of time you want devote to the required modifications.  Can you trust your programmers to remember to escape external data before using it in a query?  If the answer is "yes" then MySQLi is a good choice, even if many computer scientists would express a preference for PDO.  


If you are considering PDO, this article is worth reading, but be aware that there are errors in the article's code examples.  Read for comprehension, but don't copy the code unless you're willing to do some debugging!


Object-Oriented or Procedural?

Object-oriented.  There are no real advantages and many disadvantages if you get stuck in procedural database extensions.  So just don't do that.


From personal experience, here are the reasons why I choose object-oriented MySQLi.


1. There can be two simultaneous connections to the DB engine.  You do not have to convert all of the old MySQL code at once - you can convert it query-by-query.


2. There are almost no changes needed to the SQL query strings (in PDO almost every query string will have to change).


3. There is almost 100% 1:1 matching of functionality (in PDO some of the MySQL operations are lost, eg, data_seek() does not exist).


4. There are relatively few code changes needed.  If you were to choose procedural MySQLi instead of OOP MySQLi, every call to the query() function would have to change because the procedural version requires the database link identifier as the first argument.  The OOP version infers the database link from the MySQLi object.


5. Anybody who really believes that using PDO will somehow magically let you change out the underlying data base engine, without creating havoc in your application software, has never tried to change out an underlying data base engine.


Do I Have to Change my Query Strings?

Probably not if you choose MySQLi.  Your queries require very modest changes (if any) when you choose the MySQLi extension.  PDO is a different story.  It uses an entirely different query structure with prepared statements and bound data.  PDO does not put PHP variables into its query strings; it passes the variables separately and thus it requires changes in almost all query strings, as well as the attendant PHP programming.  


Do I Have to Change my Data Base Tables?

No.  We are changing the API extensions, but we are not changing the underlying data base tables or the essential nature of the SQL query language.


This Sounds Like a Huge Amount of Work

Yes.  You almost certainly want to use some kind of version control.  But it does not have to be a daunting "all-or-nothing" task.  You can make simultaneous connections to the MySQL server using MySQLi alongside existing MySQL API code, in the same PHP script, and you can change your queries one at a time.  I have not tested it, but I would expect that the same might be true for PDO.


What Will I Learn Here?

Each of these examples performs the same basic data base functions.  We connect to the server and select a data base, we CREATE a table and load it with data.  We run a SELECT query and count the results.  We show the results set (using two methods of access to the rows of the results set).  We DELETE a row from the table.  And finally we run a query that is designed to fail so that we can see the differences in the error output.  You can print out these three scripts and follow the logic as you read the annotation and watch them run.


Man Page References

You will need to read these online references to understand the code in the snippets below.  No excuses, just do it.  You might even want to bookmark the PHP man pages. You may also want to review this web page that provides a map of MySQL functions to the MySQLi and PDO extensions.



MySQL

// THE ABSOLUTE MINIMUM YOU MUST UNDERSTAND TO USE PHP AND MYSQL
                                        // MAN PAGE: http://php.net/manual/en/ref.mysql.php
                                        // MAN PAGE: http://php.net/manual/en/mysql.installation.php
                                        // MAN PAGE: http://php.net/manual/en/function.mysql-connect.php
                                        // MAN PAGE: http://php.net/manual/en/function.mysql-select-db.php
                                        // MAN PAGE: http://php.net/manual/en/function.mysql-real-escape-string.php
                                        // MAN PAGE: http://php.net/manual/en/function.mysql-query.php
                                        // MAN PAGE: http://php.net/manual/en/function.mysql-errno.php
                                        // MAN PAGE: http://php.net/manual/en/function.mysql-error.php
                                        // MAN PAGE: http://php.net/manual/en/function.mysql-num-rows.php
                                        // MAN PAGE: http://php.net/manual/en/function.mysql-fetch-array.php
                                        // MAN PAGE: http://php.net/manual/en/function.mysql-fetch-assoc.php
                                        // MAN PAGE: http://php.net/manual/en/function.mysql-fetch-object.php
                                        // MAN PAGE: http://php.net/manual/en/function.mysql-insert-id.php

MySQLi


// THE ABSOLUTE MINIMUM YOU MUST UNDERSTAND TO USE PHP AND MYSQLI
                                        // MAN PAGE: http://php.net/manual/en/mysqli.overview.php
                                        // MAN PAGE: http://php.net/manual/en/class.mysqli.php
                                        // MAN PAGE: http://php.net/manual/en/class.mysqli-stmt.php
                                        // MAN PAGE: http://php.net/manual/en/class.mysqli-result.php
                                        // MAN PAGE: http://php.net/manual/en/class.mysqli-warning.php
                                        // MAN PAGE: http://php.net/manual/en/class.mysqli-sql-exception.php <-- DID NOT WORK PHP 5.3+, MySQL 5.1+
                                        // MAN PAGE: http://php.net/manual/en/mysqli.construct.php
                                        // MAN PAGE: http://php.net/manual/en/mysqli.real-escape-string.php
                                        // MAN PAGE: http://php.net/manual/en/mysqli.query.php
                                        // MAN PAGE: http://php.net/manual/en/mysqli.errno.php
                                        // MAN PAGE: http://php.net/manual/en/mysqli.error.php
                                        // MAN PAGE: http://php.net/manual/en/mysqli.insert-id.php
                                        // MAN PAGE: http://php.net/manual/en/mysqli-result.num-rows.php
                                        // MAN PAGE: http://php.net/manual/en/mysqli-result.fetch-array.php
                                        // MAN PAGE: http://php.net/manual/en/mysqli-result.fetch-object.php


PDO

// THE ABSOLUTE MINIMUM YOU MUST UNDERSTAND TO USE PHP AND PDO/MYSQL
                                        // MAN PAGE: http://php.net/manual/en/book.pdo.php
                                        // MAN PAGE: http://php.net/manual/en/class.pdo.php
                                        // MAN PAGE: http://php.net/manual/en/class.pdoexception.php
                                        // MAN PAGE: http://php.net/manual/en/class.pdostatement.php
                                        // MAN PAGE: http://php.net/manual/en/pdo.construct.php
                                        // MAN PAGE: http://php.net/manual/en/pdo.setattribute.php
                                        // MAN PAGE: http://php.net/manual/en/pdo.query.php
                                        // MAN PAGE: http://php.net/manual/en/pdo.prepare.php
                                        // MAN PAGE: http://php.net/manual/en/pdo.prepare.php#97942 <-- NO CURSOR SCROLLING
                                        // MAN PAGE: http://php.net/manual/en/pdostatement.execute.php
                                        // MAN PAGE: http://php.net/manual/en/pdo.lastinsertid.php
                                        // MAN PAGE: http://php.net/manual/en/pdostatement.bindparam.php
                                        // MAN PAGE: http://php.net/manual/en/pdostatement.rowcount.php
                                        // MAN PAGE: http://php.net/manual/en/pdostatement.fetchall.php
                                        // MAN PAGE: http://php.net/manual/en/pdostatement.fetchobject.php


Test Data

Identical for MySQL, MySQLi, and PDO.  It's the first thing you need if you're going to write computer programs.  In fact it's so important that a wise programmer will write the test data first, before a single line of code is laid!

 

// CREATE AN ARRAY OF NAMES TO USE FOR TEST DATA
                                        $test_names_arrays = array
                                        ( array( "fname" => "Walter" , "lname" => "Williams" )
                                        , array( "fname" => "Ray"    , "lname" => "Paseur"   )
                                        , array( "fname" => "Bill"   , "lname" => "O'Reilly" )
                                        , array( "fname" => "Ray"    , "lname" => "Capece"   )
                                        , array( "fname" => "John"   , "lname" => "Paseur"   )
                                        )
                                        ;


Authentication Credentials

Identical for MySQL, MySQLi, and PDO. Data base authentication credentials are the same for these extensions, however PDO uses the concept of a Data Source Name (combining the Data Base Engine and the Data Base Name).

 

// DATABASE CONNECTION AND SELECTION VARIABLES - GET THESE FROM YOUR HOSTING COMPANY
                                        $db_host = "localhost"; // PROBABLY THIS IS OK
                                        $db_name = "??";
                                        $db_user = "??";
                                        $db_word = "??";


Connect to the Server and Choose the Data Base

Each of these connections has very different information available in the DB connection resource or object.  For MySQL, the connection is a resource that does not tell us very much.  For MySQLi, the connection is an object with a rich collection of information.  For PDO, the connection is an object but it has no visible properties at this point.


MySQL uses connect and select function calls. Errors can be visualized using the appropriate error messages which can be found by calling the relevant MySQL functions.


MySQLi connects to the DB server by instantiation of a new MySQLi object. Errors, if any, can be found by visualizing the appropriate error messages which are properties of the MySQLi object.


Connect/select proceeds a bit differently in PDO.  Check the cautionary notes about accidental exposure of PDO authentication data. For this reason we wrap the instantiation of the PDO object in try/catch code blocks so we can handle the exceptions in our own code, rather than having an uncaught exception expose information that should not be made public.  More information on the PDOException object can be found in the online man pages.  PDO uses the Data Source Name ("DSN") that includes both the host name and the data base name.


MySQL

// OPEN A CONNECTION TO THE DATA BASE SERVER
                                        if (!$dbcon = mysql_connect("$db_host", "$db_user", "$db_word"))
                                        {
                                            $err
                                            = "NO DB CONNECTION: $db_host: "
                                            . mysql_errno()
                                            . ' '
                                            . mysql_error()
                                            ;
                                            trigger_error($err, E_USER_WARNING);
                                        }
                                        
                                        // SELECT THE MYSQL DATA BASE
                                        if (!mysql_select_db($db_name, $dbcon))
                                        {
                                            $err
                                            = "NO DB SELECTION: $db_name: "
                                            . mysql_errno()
                                            . ' '
                                            . mysql_error()
                                            ;
                                            trigger_error($err, E_USER_WARNING);
                                            trigger_error('NO DATABASE', E_USER_ERROR);
                                        }
                                        // SHOW WHAT THE DB CONNECTION LOOKS LIKE
                                        var_dump($dbcon);

  MySQLi


// OPEN A CONNECTION TO THE DATA BASE SERVER AND SELECT THE DB
                                        $mysqli = new mysqli($db_host, $db_user, $db_word, $db_name);
                                        
                                        // DID THE CONNECT/SELECT WORK OR FAIL?
                                        if ($mysqli->connect_errno)
                                        {
                                            $err
                                            = "CONNECT FAIL: "
                                            . $mysqli->connect_errno
                                            . ' '
                                            . $mysqli->connect_error
                                            ;
                                            trigger_error($err, E_USER_ERROR);
                                        }
                                        // SHOW WHAT THE DB CONNECTION OBJECT LOOKS LIKE
                                        var_dump($mysqli);


PDO

// WARNING: AN UNCAUGHT CONNECT ERROR WILL BARK OUT THE DB CREDENTIALS!
                                        // OPEN A CONNECTION TO THE DATA BASE SERVER AND SELECT THE DB
                                        $dsn = "mysql:host=$db_host;dbname=$db_name";
                                        try
                                        {
                                            $pdo = new PDO($dsn, $db_user, $db_word);
                                        }
                                        catch(PDOException $exc)
                                        {
                                            var_dump($exc);
                                            trigger_error('NO PDO Connection', E_USER_ERROR);
                                        }
                                        // SHOW THE PDO CONNECTION OBJECT
                                        var_dump($pdo);


PDO - Error Visualization

This sets the attributes of the PDO object to control what warnings and exceptions we can see.  Without these settings, PDO is silent abouterror conditions.  This concept is similarly applicable to MySQL and MySQLi, where we have to control error visualization on a query-by-query basis.

 

// SET PDO TO TELL US ABOUT WARNINGS OR TO THROW EXCEPTIONS
                                        $pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
                                        $pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );


CREATE TABLE Query Strings

Identical for MySQL, MySQLi, and PDO. Even though our teaching example has a very simple table structure, we will be able to see that (1) the same structure works in all extensions and (2) the same query results can be retrieved in all extensions.

 

// CREATING A TABLE FOR OUR TEST DATA
                                        $sql
                                        =
                                        "
                                        CREATE TEMPORARY TABLE my_table
                                        ( id    INT         NOT NULL AUTO_INCREMENT PRIMARY KEY
                                        , fname VARCHAR(24) NOT NULL DEFAULT ''
                                        , lname VARCHAR(24) NOT NULL DEFAULT ''
                                        )
                                        "
                                        ;


Run the CREATE TABLE Query and Handle Errors/Exceptions

MySQL and MySQLi extensions use a similar-looking construct to run the query.  MySQL calls the mysql_query() function.  MySQLi calls the query() method on the MySQLi object.  The PDO extension calls the query() method on the PDO object.  We wrap this in a try/catch block that will enable us to handle any exceptional conditions. The exception, if any, will be reported to the script in the PDOException object.


MySQL

// RUN THE QUERY TO CREATE THE TABLE
                                        $res = mysql_query($sql);
                                        
                                        // IF mysql_query() RETURNS FALSE, LOG AND SHOW THE ERROR
                                        if (!$res)
                                        {
                                            $err
                                            = "QUERY FAIL: "
                                            . $sql
                                            . ' ERRNO: '
                                            . mysql_errno()
                                            . ' ERROR: '
                                            . mysql_error()
                                            ;
                                            trigger_error($err, E_USER_ERROR);
                                        }
                                        // SHOW THE RESULTS OF THE QUERY
                                        var_dump($res);

  MySQLi


// RUN THE QUERY TO CREATE THE TABLE
                                        $res = $mysqli->query($sql);
                                        
                                        // IF mysqli::query() RETURNS FALSE, LOG AND SHOW THE ERROR
                                        if (!$res)
                                        {
                                            $err
                                            = "QUERY FAIL: "
                                            . $sql
                                            . ' ERRNO: '
                                            . $mysqli->errno
                                            . ' ERROR: '
                                            . $mysqli->error
                                            ;
                                            trigger_error($err, E_USER_ERROR);
                                        }
                                        // SHOW THE RESULTS OF THE QUERY
                                        var_dump($res);


PDO

// RUN QUERY TO CREATE THE TABLE
                                        try
                                        {
                                            $pdos = $pdo->query($sql);
                                        }
                                        catch(PDOException $exc)
                                        {
                                            var_dump($exc);
                                            trigger_error($exc->getMessage(), E_USER_ERROR);
                                        }
                                        // SHOW THE RESULTS OF THE QUERY
                                        var_dump($pdos);


PDO - Prepare a Query

This code prepares a query for use by the PDO object.  We only need to prepare the query once, then it can be reused over and over with different data.  Since the query and the data are sent to the SQL engine separately, the SQL statement is protected from SQL injection.  The results of query preparation are returned to us in the form of a PDOStatement object, stored in $pdos.  Take note of line 6.  This is where we tell PDO what our input data looks like.  The colon-prefixed names are array indexes.  Important: Do not put quotes around these colon-prefixed fields!  They are named placeholders, not variables that might be used in MySQLi queries.  You can see how this lines things up if you look back at the array keys in the test data arrays.  After the query is prepared, we can call the execute() method repeatedly, passing associative arrays with named keys.  There is a query preparation analog for MySQLi, but no such preparation method for MySQL -- with MySQL we must remember to escape the data every time, and failure to escape the data correctly could result in a failed query.  Line 11 calls the prepare() method on the PDO object and returns the PDOStatement object into $pdos.


PDO

// PREPARE THE QUERY TO LOAD THE NAMES ("PREPARE" ONLY NEEDED ONCE)
                                        $sql
                                        =
                                        "INSERT INTO my_table
                                        (  fname,  lname ) VALUES
                                        ( :fname, :lname )
                                        "
                                        ;
                                        try 
                                        { 
                                            $pdos = $pdo->prepare($sql); 
                                        } 
                                        catch(PDOException $exc) 
                                        { 
                                            var_dump($exc);
                                            trigger_error($exc->getMessage(), E_USER_ERROR);
                                        }


Use an Iterator to Escape the Data and Load the Table

The programs use identical iterators, but the method calls and sequences are different.  Unlike PDO which uses prepared query statements, the MySQL and MySQLi extensions must call the mysql_real_escape_string() function or the real_escape_string() method, then use the escaped output to create the query string.


MySQL and MySQLi make the expected function/method calls.  PDO uses the execute() method on the prepared PDOStatement object.


To test for query success and show any applicable error information, MySQL and MySQLi test for FALSE return values from the function/method calls, and execute the error handler code if necessary.  PDO catches the PDOException object that would be thrown by a failing PDOStatement object.


The last insert id (AUTO_INCREMENT KEY) is retrieved on a per-connection basis.  This means that MySQL uses the data base connection resource in its call to mysql_insert_id().  For MySQLi, the number can be found in the insert_id property of the MySQLi Object.  For PDO, the script calls the lastInsertId() method on the PDO object.


MySQL

// LOADING OUR DATA INTO THE TABLE
                                        foreach ($test_names_arrays as $person)
                                        {
                                            // ESCAPE THE DATA FOR SAFE USE IN A QUERY
                                            $safe_fn  = mysql_real_escape_string($person['fname']);
                                            $safe_ln  = mysql_real_escape_string($person['lname']);
                                        
                                            // CONSTRUCT THE QUERY USING THE ESCAPED VARIABLES
                                            $sql = "INSERT INTO my_table ( fname, lname ) VALUES ( '$safe_fn', '$safe_ln' )";
                                        
                                            // RUN THE QUERY TO INSERT THE ROW
                                            $res = mysql_query($sql);
                                        
                                            // IF mysql_query() RETURNS FALSE, LOG AND SHOW THE ERROR
                                            if (!$res)
                                            {
                                                $err
                                                = "QUERY FAIL: "
                                                . $sql
                                                . ' ERRNO: '
                                                . mysql_errno()
                                                . ' ERROR: '
                                                . mysql_error()
                                                ;
                                                trigger_error($err, E_USER_ERROR);
                                            }
                                        
                                            // GET THE AUTO_INCREMENT ID OF THE RECORD JUST INSERTED - PER THE DB CONNECTION
                                            $id  = mysql_insert_id($dbcon);
                                            echo "MySQL INSERTED A ROW CONTAINING <b>$safe_fn $safe_ln</b> WITH AUTO_INCREMENT ID = $id" . PHP_EOL;
                                        }


MySQLi


// LOADING OUR DATA INTO THE TABLE
                                        foreach ($test_names_arrays as $person)
                                        {
                                            // ESCAPE THE DATA FOR SAFE USE IN A QUERY
                                            $safe_fn  = $mysqli->real_escape_string($person['fname']);
                                            $safe_ln  = $mysqli->real_escape_string($person['lname']);
                                        
                                            // CONSTRUCT THE QUERY USING THE ESCAPED VARIABLES
                                            $sql = "INSERT INTO my_table ( fname, lname ) VALUES ( '$safe_fn', '$safe_ln' )";
                                        
                                            // RUN THE QUERY TO INSERT THE ROW
                                            $res = $mysqli->query($sql);
                                        
                                            // IF mysqli::query() RETURNS FALSE, LOG AND SHOW THE ERROR
                                            if (!$res)
                                            {
                                                $err
                                                = "QUERY FAIL: "
                                                . $sql
                                                . ' ERRNO: '
                                                . $mysqli->errno
                                                . ' ERROR: '
                                                . $mysqli->error
                                                ;
                                                trigger_error($err, E_USER_ERROR);
                                            }
                                        
                                            // GET THE AUTO_INCREMENT ID OF THE RECORD JUST INSERTED
                                            $id  = $mysqli->insert_id;
                                            echo "MySQLI INSERTED A ROW CONTAINING <b>$safe_fn $safe_ln</b> WITH AUTO_INCREMENT ID = $id" . PHP_EOL;
                                        }


PDO

// LOADING OUR DATA INTO THE TABLE
                                        foreach ($test_names_arrays as $person)
                                        {
                                            // USE THE ARRAY OF KEYWORD => VALUE TO ATTACH fname AND lname
                                            try
                                            {
                                                // RUN THE QUERY TO INSERT THE ROW
                                                $pdos->execute($person);
                                            }
                                            catch(PDOException $exc)
                                            {
                                                var_dump($exc);
                                                trigger_error($exc->getMessage(), E_USER_ERROR);
                                            }
                                        
                                            // GET THE AUTO_INCREMENT ID OF THE RECORD JUST INSERTED
                                            $id  = $pdo->lastInsertId();
                                            echo "PDO INSERTED A ROW CONTAINING <b>" . $person['fname'] . ' ' . $person['lname']. "</b> WITH AUTO_INCREMENT ID = $id" . PHP_EOL;
                                        }


Create and Execute a SELECT Query

Both MySQL and MySQLi extensions follow similar patterns to escape the external data and substitute the escaped string into the SQL statement.  After the query has been run MySQL has a resource id in $res and MySQLi has a results object.


With the PDO extension we do not need to escape the external data because the data is not put into the query string, but is sent to the SQL engine separately.  Instead we create the query string using the colon-prefixed name that we will pass to the bindParam() method.  We prepare the query on line 7 of the PDO example.  


Note that the prepare process is intended to give us a scrollable results set "cursor" which would, in theory, enable us to retrieve the rows of the results set in any order we chose.  But alas, this tool is unavailable in PHP's implementation of PDO for MySQL data bases.  In spite of being a high-value request, PHP has not implemented it.  Next, we bind the :fname column with the $fname variable using the PDO::PARAM_STR constant to tell PDO that this is a string binding and not an array binding.  Then we try to execute the query.


MySQL

// CREATE AND SEND A SELECT QUERY AND TEST THE RESULTS
                                        $fname    = "RAY";
                                        $safe_fn  = mysql_real_escape_string($fname);
                                        
                                        // CONSTRUCT THE QUERY USING THE ESCAPED VARIABLE
                                        $sql = "SELECT id, lname FROM my_table WHERE fname='$safe_fn' ORDER BY lname, fname";
                                        $res = mysql_query($sql);
                                        
                                        // IF mysql_query() RETURNS FALSE, LOG AND SHOW THE ERROR
                                        if (!$res)
                                        {
                                            $err
                                            = "QUERY FAIL: "
                                            . $sql
                                            . ' ERRNO: '
                                            . mysql_errno()
                                            . ' ERROR: '
                                            . mysql_error()
                                            ;
                                            trigger_error($err, E_USER_ERROR);
                                        }
                                        // IF SCRIPT GETS HERE WE HAVE A RESOURCE-ID IN $res


MySQLi


// CREATE AND SEND A SELECT QUERY AND TEST THE RESULTS
                                        $fname    = "RAY";
                                        $safe_fn  = $mysqli->real_escape_string($fname);
                                        
                                        // CONSTRUCT THE QUERY USING THE ESCAPED VARIABLE
                                        $sql = "SELECT id, lname FROM my_table WHERE fname='$safe_fn' ORDER BY lname, fname";
                                        $res = $mysqli->query($sql);
                                        
                                        // IF mysqli_query() RETURNS FALSE, LOG AND SHOW THE ERROR
                                        if (!$res)
                                        {
                                            $err
                                            = "QUERY FAIL: "
                                            . $sql
                                            . ' ERRNO: '
                                            . $mysqli->errno
                                            . ' ERROR: '
                                            . $mysqli->error
                                            ;
                                            trigger_error($err, E_USER_ERROR);
                                        }
                                        // IF SCRIPT GETS HERE WE HAVE A RESULT OBJECT IN $res


PDO

$fname    = "RAY";
                                        
                                        // CREATE A QUERY FOR USE WITH BINDPARAM()
                                        $sql = "SELECT id, lname FROM my_table WHERE fname = :fname ORDER BY lname, fname";
                                        
                                        // CURSOR_SCROLL ALLOWS REPOSITIONING THE CURSOR - LIKE DATA_SEEK() - BUT SADLY NOT WITH MYSQL
                                        $pdos = $pdo->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
                                        
                                        // BIND THE VARIABLE AND TRY THE QUERY
                                        $pdos->bindParam(':fname', $fname, PDO::PARAM_STR);
                                        
                                        try
                                        {
                                            $pdos->execute();
                                        }
                                        catch(PDOException $exc)
                                        {
                                            var_dump($exc);
                                            trigger_error($exc->getMessage(), E_USER_ERROR);
                                        }


Find the Number of Rows in the Results Set

For MySQL, the number is found by calling the mysql_num_rows() function and passing it the $res resource from the query.  With MySQLi, the number is found in the num_rows property of the $resmysqli_result object.  With PDO, the number is usually found by calling the rowCount() method on the PDOStatement object.  But... the rowCount() method may not always give you exactly what you want to know!  Please see the man page for rowCount() and read the user-contributed notes to learn about the potential ambiguities.


MySQL

// DETERMINE HOW MANY ROWS OF RESULTS WE GOT
                                        $num     = mysql_num_rows($res);
                                        $num_fmt = number_format($num);
                                        if (!$num)
                                        {
                                            echo "<br/>QUERY: $sql ";
                                            echo "<br/>FOUND NO DATA ";
                                            echo PHP_EOL;
                                        }
                                        else
                                        {
                                            echo "<br/>QUERY: $sql ";
                                            echo "<br/>FOUND $num_fmt ROWS OF DATA ";
                                            echo PHP_EOL;
                                        }


MySQLi

// DETERMINE HOW MANY ROWS OF RESULTS WE GOT
                                        $num     = $res->num_rows;
                                        $num_fmt = number_format($num);
                                        if (!$num)
                                        {
                                            echo "<br/>QUERY: $sql ";
                                            echo "<br/>FOUND NO DATA ";
                                            echo PHP_EOL;
                                        }
                                        else
                                        {
                                            echo "<br/>QUERY: $sql ";
                                            echo "<br/>FOUND $num_fmt ROWS OF DATA ";
                                            echo PHP_EOL;
                                        }


PDO

// DETERMINE HOW MANY ROWS OF RESULTS WE GOT
                                        $num     = $pdos->rowCount();
                                        $num_fmt = number_format($num);
                                        if (!$num)
                                        {
                                            echo "<br/>QUERY: $sql ";
                                            echo "<br/>FOUND NO DATA ";
                                            echo PHP_EOL;
                                        }
                                        else
                                        {
                                            echo "<br/>QUERY: $sql ";
                                            echo "<br/>FOUND $num_fmt ROWS OF DATA ";
                                            echo PHP_EOL;
                                        }


Retrieve the Rows of the Results Set

Using MySQL, the rows are retrieved using the mysql_fetch_array() function .  This function was chosen to illustrate why you should not use this function.  Unless you tell it otherwise, it retrieves twice as much data as is necessary to bring back the answers!  The output from print_r() will show what is going on.


With MySQLi, the rows are retrieved using the fetch_array() method on the MySQLI_Result object.  Like mysql_fetch_array() this method retrieves twice as much data is is needed to process the results.  Better choices are shown below


In the PDO example, the rows are retrieved into an array of objects by calling the fetchAll() method on the PDOStatement object. Each of these objects has a property with the name of the column name and a value equal to the column value in the respective row.  You can also retrieve the rows into a "record set" structure, which is a two-dimensional array of arrays, where the main array contains all of the rows, and each row is represented by an associative array.  A useful function for processing record sets is array_column().


MySQL

// ITERATE OVER THE RESULTS SET AS AN ARRAY TO SHOW WHAT WE FOUND
                                        echo "USING MySQL_Fetch_<i>Array</i>(): ";
                                        echo PHP_EOL;
                                        while ($row = mysql_fetch_array($res))
                                        {
                                            // ROW BY ROW PROCESSING IS DONE HERE
                                            print_r($row);
                                            echo PHP_EOL;
                                        }


MySQLi


// ITERATE OVER THE RESULTS SET AS AN ARRAY TO SHOW WHAT WE FOUND
                                        echo "USING MySQLi_Result::Fetch_<i>Array</i>(): ";
                                        echo PHP_EOL;
                                        while ($row = $res->fetch_array())
                                        {
                                            // ROW BY ROW PROCESSING IS DONE HERE
                                            print_r($row);
                                            echo PHP_EOL;
                                        }


PDO

// ITERATE OVER THE RESULTS SET TO SHOW WHAT WE FOUND
                                        echo "USING PDOStatement::FetchAll(PDO::FETCH_OBJ): ";
                                        echo "<br/>" . PHP_EOL;
                                        while ($row = $pdos->fetchAll(PDO::FETCH_OBJ))
                                        {
                                            // ROW BY ROW PROCESSING IS DONE HERE
                                            foreach ($row as $key => $obj)
                                            {
                                                echo "$key: ";
                                                print_r($obj);
                                                echo PHP_EOL;
                                            }
                                        }


Reset the Results Set Pointer

MySQL and MySQLi can reset the results set pointer in the existing results set.  We do not need to rerun the query to get to the same data for a different view.  The PHP MySQL PDO implementation does not support this.  The first row of the results set is numbered the same way as the first element of an array.  Numbering starts with zero.


MySQL

// RESET THE RESULTS SET POINTER TO THE TOP
                                        mysql_data_seek($res,0);


MySQLi


// RESET THE RESULTS SET POINTER TO THE TOP
                                        $res->data_seek(0);


Retrieve the Rows of the Results Set (Again)

With MySQL and MySQLi, each row is retrieved in the form of an object with the column name representing a property of the object that points to the value from the row of the database.  In PDO, a second retrieval is not possible; the query must be rerun, or the original results set must be saved in PHP variables so the values can be reused.


Note that retrieving the rows in the form of  objects creates an easy-to-use syntax to incorporate the results inHEREDOCvariables!  If you retrieve the rows in the form of arrays, the quoted variables must be encapsulated in curly braces for HEREDOC, making the syntax inconvenient and much harder to get right.


MySQL

// ITERATE OVER THE RESULTS SET AS AN OBJECT TO SHOW WHAT WE FOUND
                                        echo "USING MySQL_Fetch_<i>Object</i>(): ";
                                        echo PHP_EOL;
                                        while ($row = mysql_fetch_object($res))
                                        {
                                            // ROW BY ROW PROCESSING IS DONE HERE
                                            print_r($row);
                                            echo PHP_EOL;
                                        }


MySQLi


// ITERATE OVER THE RESULTS SET AS AN OBJECT TO SHOW WHAT WE FOUND
                                        echo "USING MySQLi_Result::Fetch_<i>Object</i>(): ";
                                        echo PHP_EOL;
                                        while ($row = $res->fetch_object())
                                        {
                                            // ROW BY ROW PROCESSING IS DONE HERE
                                            print_r($row);
                                            echo PHP_EOL;
                                        }


Delete a Row From the Table

MySQL and MySQLi extensions follow similar patterns to escape the external data and substitute the escaped string into the SQL statement. The PDO extension uses the by-now-familiar :name notation with colons prepended to the array index name to prepare the query statement and bind the PHP variable.  A try/catch block encloses the call to the query handler.


MySQL

// DELETE A ROW FROM THE TABLE
                                        $lname   = "O'Reilly";
                                        $safe_ln = mysql_real_escape_string($lname);
                                        
                                        // CONSTRUCT AND RUN A QUERY TO DELETE
                                        $sql = "DELETE FROM my_table WHERE lname = '$safe_ln' LIMIT 33";
                                        $res = mysql_query($sql);
                                        
                                        // IF mysql_query() RETURNS FALSE, LOG AND SHOW THE ERROR
                                        if (!$res)
                                        {
                                            $err
                                            = "QUERY FAIL: "
                                            . $sql
                                            . ' ERRNO: '
                                            . mysql_errno()
                                            . ' ERROR: '
                                            . mysql_error()
                                            ;
                                            trigger_error($err, E_USER_ERROR);
                                        }


MySQLi


// DELETE A ROW FROM THE TABLE
                                        $lname   = "O'Reilly";
                                        $safe_ln = $mysqli->real_escape_string($lname);
                                        
                                        // CONSTRUCT AND RUN A QUERY TO DELETE
                                        $sql = "DELETE FROM my_table WHERE lname = '$safe_ln' LIMIT 33";
                                        $res = $mysqli->query($sql);
                                        
                                        // IF mysqli::query() RETURNS FALSE, LOG AND SHOW THE ERROR
                                        if (!$res)
                                        {
                                            $err
                                            = "QUERY FAIL: "
                                            . $sql
                                            . ' ERRNO: '
                                            . $mysqli->errno
                                            . ' ERROR: '
                                            . $mysqli->error
                                            ;
                                            trigger_error($err, E_USER_ERROR);
                                        }


PDO

// DELETE A ROW FROM THE TABLE
                                        $lname   = "O'Reilly";
                                        
                                        // CONSTRUCT AND RUN A QUERY TO DELETE
                                        $sql = "DELETE FROM my_table WHERE lname = :lname LIMIT 33";
                                        
                                        // BIND THE VARIABLE AND TRY THE QUERY
                                        $pdos = $pdo->prepare($sql);
                                        $pdos->bindParam(':lname', $lname, PDO::PARAM_STR);
                                        try
                                        {
                                            $pdos->execute();
                                        }
                                        catch(PDOException $exc)
                                        {
                                            var_dump($exc);
                                            trigger_error($exc->getMessage(), E_USER_ERROR);
                                        }


Determine the Number of Affected Rows

MySQL calls the mysql_affected_rows() function referencing the data base connection. MySQLi reads the affected_rows property from the MySQLi object. PDO calls the rowCount() method on the PDOStatement object.


MySQL

// HOW MANY ROWS WERE AFFECTED BY DELETE?
                                        $num     = mysql_affected_rows($dbcon);
                                        $num_fmt = number_format($num);
                                        if (!$num)
                                        {
                                            echo "<br/>QUERY: $sql ";
                                            echo "<br/>AFFECTED NO DATA ";
                                            echo PHP_EOL;
                                        }
                                        else
                                        {
                                            echo "<br/>QUERY: $sql ";
                                            echo "<br/>AFFECTED $num_fmt ROWS OF DATA ";
                                            echo PHP_EOL;
                                        }


MySQLi


// HOW MANY ROWS WERE AFFECTED BY DELETE?
                                        $num     = $mysqli->affected_rows;
                                        $num_fmt = number_format($num);
                                        if (!$num)
                                        {
                                            echo "<br/>QUERY: $sql ";
                                            echo "<br/>AFFECTED NO DATA ";
                                            echo PHP_EOL;
                                        }
                                        else
                                        {
                                            echo "<br/>QUERY: $sql ";
                                            echo "<br/>AFFECTED $num_fmt ROWS OF DATA ";
                                            echo PHP_EOL;
                                        }

PDO

 

// HOW MANY ROWS WERE AFFECTED BY DELETE?
                                        $num     = $pdos->rowCount();
                                        $num_fmt = number_format($num);
                                        if (!$num)
                                        {
                                            echo "<br/>QUERY: $sql ";
                                            echo "<br/>AFFECTED NO DATA ";
                                            echo PHP_EOL;
                                        }
                                        else
                                        {
                                            echo "<br/>QUERY: $sql ";
                                            echo "<br/>AFFECTED $num_fmt ROWS OF DATA ";
                                            echo PHP_EOL;
                                        }


Visualize Error and Exception Information

A defective query is created to cause a failure of the MySQL server.  Each of the MySQL extensions creates its own error information, which is displayed by the script.  The PDOException object is far more comprehensive in its information.  It would require considerable programming to get this kind of detailed information from MySQL or MySQLi. In the case of PDO, note that the PDOStatement object is not modified by the query failure and still contains the previous query statement.


MySQL

// CONSTRUCT A QUERY THAT WILL FAIL
                                        $sql = "SELECT oopsie FROM my_table ";
                                        $res = mysql_query($sql);
                                        
                                        // SHOW THE ERROR INFORMATION
                                        if (!$res)
                                        {
                                            $err
                                            = "QUERY FAIL: "
                                            . $sql
                                            . ' ERRNO: '
                                            . mysql_errno()
                                            . ' ERROR: '
                                            . mysql_error()
                                            ;
                                            echo $err;
                                        }


QUERY FAIL: SELECT oopsie FROM my_table  ERRNO: 1054 ERROR: Unknown column 'oopsie' in 'field list'


MySQLi


// CONSTRUCT A QUERY THAT WILL FAIL
                                        $sql = "SELECT oopsie FROM my_table ";
                                        $res = $mysqli->query($sql);
                                        
                                        // SHOW THE ERROR INFORMATION
                                        if (!$res)
                                        {
                                            $err
                                            = "QUERY FAIL: "
                                            . $sql
                                            . ' ERRNO: '
                                            . $mysqli->errno
                                            . ' ERROR: '
                                            . $mysqli->error
                                            ;
                                            echo $err;
                                        }


QUERY FAIL: SELECT oopsie FROM my_table  ERRNO: 1054 ERROR: Unknown column 'oopsie' in 'field list'


PDO

// CONSTRUCT A QUERY THAT WILL FAIL
                                        $sql = "SELECT oopsie FROM my_table ";
                                        try
                                        {
                                            $pdos = $pdo->query($sql);
                                        }
                                        catch(PDOException $exc)
                                        {
                                            // SHOW PDOException AND PDOStatement
                                            var_dump($exc);
                                            var_dump($pdos);
                                        }


object(PDOException)#5 (8) {
                                          ["message":protected]=>
                                          string(79) "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'oopsie' in 'field list'"
                                          ["string":"Exception":private]=>
                                          string(0) ""
                                          ["code":protected]=>
                                          string(5) "42S22"
                                          ["file":protected]=>
                                          string(49) "/home/account/public_html/RAY_EE_pdo_example.php"
                                          ["line":protected]=>
                                          int(284)
                                          ["trace":"Exception":private]=>
                                          array(1) {
                                            [0]=>
                                            array(6) {
                                              ["file"]=>
                                              string(49) "/home/account/public_html/RAY_EE_pdo_example.php"
                                              ["line"]=>
                                              int(284)
                                              ["function"]=>
                                              string(5) "query"
                                              ["class"]=>
                                              string(3) "PDO"
                                              ["type"]=>
                                              string(2) "->"
                                              ["args"]=>
                                              array(1) {
                                                [0]=>
                                                string(28) "SELECT oopsie FROM my_table "
                                              }
                                            }
                                          }
                                          ["previous":"Exception":private]=>
                                          NULL
                                          ["errorInfo"]=>
                                          array(3) {
                                            [0]=>
                                            string(5) "42S22"
                                            [1]=>
                                            int(1054)
                                            [2]=>
                                            string(39) "Unknown column 'oopsie' in 'field list'"
                                          }
                                        }
                                        object(PDOStatement)#3 (1) {
                                          ["queryString"]=>
                                          string(50) "DELETE FROM my_table WHERE lname = :lname LIMIT 33"
                                        }


Conclusion

With more than 8 years of experience using the PDO Extension API, we can be confident that the API is debugged and ready for "prime time."  The same can be said for the MySQLi Extension.  And given the current status of MySQL, it's time to upgrade our scripts.  This article has shown some links to the relevant man pages and some examples that illustrate the programming changes required to keep our programming running in the modern age.


The MySQL Obsolete Complete Code Example


30
 
LVL 110

Author Comment

by:Ray Paseur
Comment Utility
@COBOLdinosaur:  I am seeing the same.  I have also verified that you can open simultaneous MySQL and MySQLi connections to the data base server and run some queries one way and other queries another.  I have not tested this with PDO yet, but I expect that PDO will also facilitate multiple connections.  All of this will make the transitions easier.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
I am in the process of migrating now, and I can confirm that using bth types of connects works fine.  There is a slight cost in DB overhead (less than .1%), and I am not see any response time penalty using them together.  

It means rather than having to take an outage and rush through a mass move, I can mix and match and do a slow careful migrate of single modules and avoid ooops! moments.  Once I have everything migrated, I will be able to cutover to PHP 5.5 knowing that everything ran in PHP in a test environment; so all it will take is changing the parser to 5.5 because all the code is know to run at that level.

Best of all ZERO DOWN TIME for a complete migration to PHP 5.5 including converting to PDO.

Cd&
1

Web Applications

14K

Solutions

14K

Contributors

Web applications are systems that run in browsers that perform functions normally associated with other client-based programs. One of the most commonly used web applications is email; instead of downloading individual emails to a local machine, the data is shown through a website. Other examples of web applications are collaborative systems like a wiki or an online game.