Skip to main content

Posts

Showing posts from December, 2021

Difference between Abstract class and Interfaces.

Abstract class: Abstract class comes under partial abstraction. Abstract classes can maintain abstract methods and non abstract methods. In abstract classes, we can create the variables. In abstract classes, we can use any access specifier. By using 'extends' keyword we can access the abstract class features from derived class. Multiple inheritance is not possible. Interface: Interface comes under fully abstraction. Interfaces can maintain only abstract methods. In interfaces, we can't create the variables. In interface, we can use only public access specifier. By using 'implement' keyword we can get interface from derived class. By using interfaces multiple inheritance is possible.

What is the difference between MySQL, MySQLi and PDO?

To understand the difference between MySQL, MySQLi, and PDO, we must know about each one of them individually. These are nothing but the APIs of PHP that is used to access the MySQL databases and tables. The developers can choose either one of them for their project, however, it must be known that MySQLi cannot be used with PHP 7 and its newer versions. However, developers can use MySQLi with PHP 5, which is now deprecated. Let’s have some more information about each of them: MySQL:  This was the main extension that was designed to help PHP applications send and receive data from MySQL database. However, use of MySQL has been deprecated and removed as of PHP 7 and its newer versions. This is why it is not recommended for new projects, and that’s the reason why MySQLi and PDO extensions are used more nowadays. MySQLi:  The ‘i’ in MySQLi stands for Improved. Therefore, this is also known as the improved version of MySQL. It has many new features that will be covered later in the article.

The Difference Between Abstract Class and Interface in PHP

  Introduction    Before diving deep into the difference between abstract class and interface ,  you must understand one basic thing: these are two completely different classes that cannot be used as an alternative to one another.   Interface classes completely empty the shells while expecting child classes to implement everything for them. Abstract classes not only contain the common piece of information between the shells inside but also expect the child classes within to fill in the gaps.   Let us dive in a bit deeper to actually understand the difference minutely.   If you want to read about PHP Array questions then you can visit here. This will help you crack your PHP interviews.

What is a foreign key? Write a query to implement the same in MySQL.

  A foreign key is used to connect two tables. A FOREIGN KEY is a field (or assortment of it) in one table that alludes to the PRIMARY KEY in another table. The FOREIGN KEY requirement is utilised to forestall activities that would crush joins between tables. To assign a foreign key, it is important to mention it while creating the table. It can be assigned by invoking the FOREIGN KEY query. Something like this: FOREIGN KEY (Any_ID) REFERENCES Table_to_reference(Any_ID)

What are the tables in MySQL? Explain the types.

  This is a must-know  MySQL interview question . Let’s see the answer- MySQL stores everything in logical tables. Tables can be thought of as the core storage structure of MySQL. And hence tables are also known as storage engines. Here are the storage engines provided by MySQL: ·  MyISAM  – MyISAM is the default storage engine for MySQL. It extends the former ISAM storage engine. MyISAM offers big storage, up to 256TB! The tables can also be compressed to get extra storage. MyISAM tables are not transaction-safe.  ·  MERGE  – A MERGE table is a virtual table that consolidates different MyISAM tables that have a comparable structure to one table. MERGE tables use the indexes of the base tables, as they do not have indexes of their own.