Why Many Good Developers Don’t Get a Good Job?

Abdullah Karim

I have seen a lots of really good developers looking for work and they don’t find good work for months or years. On the other hand I’ve seen some really good companies looking for developers and they don’t find good developer for months or years. What’s the problem? After looking at the situation of some of the developers and companies I have tried to find out the reason behind it. Let me share my thoughts with you.

What Made Me Think?

First of all let me tell you what made me think about it. I work for K-Tabs, a company based in Canada and I work from Karachi, Pakistan. I am really very happy working with them, they are very good guys, they pay well and they have everything to attract a really good developer. They are also very happy with me and they want to keep me.

Recently…

View original post 914 more words

PHP Object-Oriented And MySQLi Procedural Interface

MySQLi is a new improved extension for accessing mysql database. It allows procedural and object oriented interface for accessing mysql database. Though you can use the old mysql functions but new mysqli offers security, advanced options, speed and similar syntax. So if you’re trying to write code using old mysql functions, just switch to mysqli. You have nothing to lose even if you don’t know how to use Object oriented way of accessing the database.

Advantages of using Mysqli over Old Mysql Extension

  • Security
  • Similar Syntax
  • Maintainable
  • Speed
  • Advanced Option
  • Support for procedural and OOP interface

In this tutorial, we are going to take a look at old way of accessing the database and then going to write the code for the procedural and object-oriented way of writing code.

Old way of accessing mysql database is something like this :

//connect to database
$con = mysql_connect("localhost", "username", "password");
 
// select database
//$db= mysql_select_db("database") or die(mysql_error());
 
//Write query
$query= "SELECT* from tablename";
 
//Fetch Results
$result=mysql_query($query);
 
//Display result
while($row=mysql_fetch_array($result))
{
// acccess the table elements and display it
}
 
//mysql close connection
mysql_close($con);

Now that was the old way for accessing the mysql database. We are going to take a look at how you’re going to access the database using new mysql drive – mysqli in procedural way.

Mysqli Procedural

//Connect to the database
$con=mysqli_connect("localhost", username", "password", "database") or die(mysqli_connect_error());
 
//Write query
$query="SELECT * from tablename";
 
//Fetch results
$result=mysqli_query($con, $query);
 
//Display results
while($row=mysqli_fetch_array($result))
{
//use row to fetch the element of each column
}
 
//close connection
mysqli_close($con);

That was easy, isn’t it? There is hardly anything you have to learn for accessing the database differently. Now we’ll take a look at how to access the database using object oriented interface.

Object Oriented Interface

//connect to database
$mysqli = new mysqli("localhost", "username", "password", "database");
 
//check for errors
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: " . $mysqli->connect_error;
}
 
//write query
$res = $mysqli->query("SELECT  * from tablename");
 
//fetch query
$row = $res->fetch_assoc();
 
//display results
echo $row['table_id'];

If you’re not comfortable with OOP then you can always go with the procedural way of accessing database. That doesn’t mean you should ignore the OOP way because If you’re dealing with postgresql or any other database, using the PDO is much better as it allows you to switch between the mysql or postgre without having to worry about extension or writing any different functions to access the database.

Note: Avoid mixing procedural and Object oriented style to access the database. Mysqli is more powerful and better way to access the database compared to the old way of accessing the database. Also learn about how to write the prepared statements using mysqli.

Where to go from here?

I suggest checking out the Mysqli Manual and learn about OO interface for accessing the database, If you haven’t already. That said, In future articles for PHP I am going to review PDO for accessing the mysql database. Please feel free to let me know If there are any errors in this article and also if you have anything to improve this article.

Source Onecore

MySQL vs. MySQLi

MySQL is the very popular open-source relational database management system which is used by popular high-volume websites such as Wikipedia, Google, Facebook, YouTube and Twitter as well as many others across the globe. This original version of MySQL is low-cost, easy to use, install and integrate, is flexible across many different platforms and is very reliable and scalable and performs well. As a result, over 100 millions copies of the software have been downloaded or distributed throughout its existence.

The follow up to MySQL, MySQLi is one of several options used ContinuousImprovementto interact with and utilize the special features of MySQL. Like the “i” at the end of the name suggests, it is an enhanced and improved PHP interface to the original MySQL. Some of the improvements to the system include more interfacing capabilities, support for prepared and multiple statements as well as enhanced debugging support. MySQLi is not an alternative to MySQL but a method for interacting with it.

What’s Different About MySQLi?

As mentioned before, MySQLi is one of three ways to interact with a MySQL database server. The other two are the MySQL Extension, which deals with older versions of MySQL, and the simpler, more portable PHP Data Objects (PDO). Like the Extension, the new MySQLi was designed to better and more fully interact with MySQL, with the new and improved one dealing with MySQL versions 4.1.3, as well as newer editions and can be found in PHP versions 5 and later. Here are some of the differences between the original MySQL and the improved MySQLi.

  • Dual object-oriented (OO) and procedural interfaces – This versatility was absent in previous version of MySQL. The procedural interface may be preferred by users migrating over from the old MySQL system, with function names differing only in prefix (simply add an “i). The object-oriented interface shows functions grouped by their purpose, making for an easier start. The two interfaces perform similarly with user preference being the deciding factor between the two.
  • Support for prepared statements – Bringing MySQL/PHP up to date with other platforms, MySQLi is able to pass a query without any data to MySQL. After binding the parameters, the query is executed. This process results in increased performance, convenience for the developer and more security by preventing SQL injection attacks.
  • Ability to process multiple statements – The ability to string together multiple statements in one statement string reduces client-server round trips. The individual statements that make up the string are separated by semicolons, then the results of each executed statement are fetched.
  • Embedded server support – MySQLi offers methods of connecting and manipulating embedded MySQL server libraries.
  • Enhanced debugging capabilities – Users are able to enter debugging queries into the system which results in a more efficient development process. An example of MySQLi debugging query would read: mysqli_debug(“d:t:o,/tmp/client.trace”)
  • Support for ability to use transactions –  Using transactions allows you to input a group of queries that execute but do not save their effects in the database. This is helpful if you have multiple inserts that rely on each other, if one fails, the others can be rolled back and none of the data is inserted.

The Pros and Cons of the Changes

While MySQLi has its advantages in interfacing with MySQL, the other options sometimes have a leg up and may be a better fit for the user, depending on personal preference and convenience. Like most things, the option that works best depends on whom you ask and what situation you need MySQLi or its competitors for.

Pros

  1. MySQLi’s interface is similar to the older MySQL interface. This versatility in using both object-oriented and procedural formats makes it easier for users of the older system to make the change to the improved one, as well as facilitating use for people that are completely new to the system. Using the old system, the user would enter a function looking like this: mysql_connect(), using the new system, this old code can be updated simply by changing the function to this: mysqli_connect().
  2. MySQLi has good support and maintenance, making the transition to and use of the new system safe and secure.
  3. The user has the ability to utilize new features available in the newest versions of MySQL servers. This is one of the biggest advantages of MySQLi. Other platforms are unable to take full advantage of MySQL’s newest capabilities.
  4. The installation process with MySQLi not only easy, but is automatic when the PHP5 MySQL package is installed in Windows or Linux.
  5. MySQLi performs (slightly) faster than its competition. With non-prepared statements, the system performs  ~2.5% faster, and ~6.5% faster with prepared ones. This is only a slight advantage and may only matter to certain users.

Cons

  1. MySQLi only works with MySQL databases, whereas PDO is flexible and able to work with multiple database systems, including IBM, Oracle and MySQL. If you have to switch databases, MySQLi is not the best option.
  2. MySQLi is not as portable as PDO.
  3. Binding parameters with MySQLi is not as easy or flexible as with PDO. MySQLi uses a numbered binding system and doesn’t support named parameters like PDO does.

Like any software updates and improvements, there are bound to be bugs to be worked out in future versions as well as adherents to the older versions or alternates. Choosing MySQLi over PDO or the MySQL Extension depends on the user’s situation and preferences. While some options are objectively better than others, what it boils down to are the preferences of the user. MySQLi is a secure and versatile option to interacting with the classic MySQL database management system and in fact earns the little “i” at the end of its name.

Source : Udemy

Php Histroy

PHP is a server-side scripting language designed for web development but also used as a general-purposec0d23d2d6769e53e24a1b3136c064577-php_logo programming language. As of January 2013, PHP was installed on more than 240 million websites (39% of those sampled) and 2.1 million web servers.

Originally created by Rasmus Lerdorf in 1994, the reference implementation of PHP (powered by the Zend Engine) is now produced by The PHP Group. While PHP originally stood for Personal Home Page,

it now stands for PHP: Hypertext Preprocessor.

Histroy Of Rasmus Lerdorf:

imagesRasmus Lerdorf (born 22 November 1968) is a  programmer with Canadian citizenship. He created the PHP scripting language, authoring the first two versions of the language and participated in the development of later versions led by a group of developers including Jim Winstead who later created blo.gs), Stig Bakken, Shane Caraveo, Andi Gutmans and Zeev Suraski. He continues to contribute to the project.

He contributed to the Apache HTTP Server and he added the LIMIT clause to the MSQL DBMS. The LIMIT clause was later adapted by several other DBMS like SQL.

From September 2002 to November 2009:

He was employed by Yahoo! Inc. as an Infrastructure Architecture Engineer.

 In 2010:

He joined WePay in order to develop their application programming interface.

On 22 February 2012

He joined Etsy(Etsy is an e-commerce website focused on handmade or second-hand or used good items and supplies, as well as unique factory-manufactured items).

In July, 2013

Rasmus joined Jelastic(Java Elastic is a Platform-as-Infrastructure (PAI) cloud computing service that provides networksservers, and storagesolutions to software development clients, enterprise businesses) as a senior advisor to help them with the creation of new technology.

Histroy Of PHP:

PHP development began in 1994 when Rasmus Lerdorf wrote a series of Common Gateway Interface (CGI) binaries in C, which he used to maintain his personal homepage. He extended them to add the ability to work with web forms and to communicate with databases, and called this implementation “Personal Home Page/Forms Interpreter” or PHP/FI.

PHP/FI could be used to build simple, dynamic web applications. Lerdorf initially announced the release of PHP/FI as “Personal Home Page Tools (PHP Tools) version 1.0” publicly to accelerate bug location and improve the code. This release already had the basic functionality that PHP has.

In November 1997

A development team began to form and, after months of work and beta testing, officially released PHP/FI 2

In 1997

Zeev Suraski and Andi Gutmans rewrote the parser(A parser is a software component that takes input data (frequently text) and builds a data structure) and formed the base of PHP 3, changing the language’s name to the recursive acronym PHP: Hypertext Preprocessor.

Afterwards, public testing of PHP 3 began.

In June 1998

The PHP3 official launch came.

In 1999

Suraski and Gutmans then started a new rewrite of PHP’s core, producing the Zend Engine(The Zend Engine is the open source scripting engine that interprets the PHP programming language. The first version of the Zend Engine appeared in 1999 in PHP version 4. The current version is The Zend Engine II at the heart of PHP 5.)

On May 22, 2000

 PHP 4, powered by the Zend Engine 1.0, was released.

On July 13, 2004

PHP 5 was released, powered by the new Zend Engine II.PHP 5 included new features such as improved support for object-oriented programming.

In 2005

A project headed by Andrei Zmievski was initiated to bring native Unicode support throughout PHP Since this would cause major changes both to the internals of the language and to user code.

In 2013

This included Perl-like variables, form handling, and the ability to embed HTML. The syntax resembled that of Perl but was simpler, more limited and less consistent.

As of 2014

There is an ongoing work on new major PHP version, named PHP 7

PHP 7 will also contain an improved variable syntax which is internally consistent and complete, which is a long-standing issue in PHP. This will allow use of ->, [], (), {}, and :: operators with arbitrary meaningful left-hand-side expressions.

The mascot of the PHP project is the elePHPant, a blue (sometimes differently colored when in plush toy form) elephant with the PHP logo on its side

USE Of PHP:

PHP is a general-purpose scripting language that is especially suited to server-side web development, in  which case PHP generally runs on a web server. Any PHP code in a requested file is executed by the PHP runtime, usually to create dynamic web page content or dynamic images used on websites or elsewhere

As of February 2014

PHP was the most-used open source software within enterprises

Web content management systems written in PHP

  • MediaWiki
  • Joomla
  • eZ Publish
  • SilverStripe
  • WordPress
  • Drupal

Popular Sites Build in Using PHP:

  • Wikipedia
  • Facebook
  • Udemy

Advantages Of PHP:

  • Open source: It is developed and maintained by a large group of PHP developers, this will helps in creating a support community, abundant extension library.
  • Speed: It is relative fast since it uses much system resource.
  • Easy to use: It uses C like syntax, so for those who are familiar with C, it’s very easy for them to pick up and it is very easy to easycreate website scripts.
  • Stable: Since it is maintained by many developers, so when bugs are found, it can be quickly fixed.
  • Powerful library support: You can easily find functional modules you need such as PDF, Graph etc.
  • Built-in database connection modules: You can connect to database easily using PHP, since many websites are data/content driven, so we will use database frequently, this will largely reduce the development time of web apps.
  • Can be run on many platforms, including Windows, Linux and Mac, it’s easy for users to find hosting service providers.

Disadvantages Of PHP:

  • Security : Since it is open sourced, so all people can see the source code, if there are bugs in the source code, it can be used by people to explore the weakness of PHP
  • Not suitable for large applications: Hard to maintain since it is not very modular.
  • Weak type:  Implicit conversion may surprise unwary programmers and lead to unexpected bugs. For example, the strings “1000” and “1e3” compare equal because they are implicitly cast to floating point numbers.