Blog
PHP Lessons - Lesson 3.6 - Working with MySQL DB. Types of JOIN operator.
In MySQL, JOIN queries can be written in several different ways. We'll try to cover all of them. Here's a list of JOIN query types:
- INNER JOIN
- LEFT JOIN
- LEFT JOIN without matches in the right table
- RIGHT JOIN
- RIGHT JOIN without matches in the left table
- FULL OUTER JOIN
- FULL OUTER JOIN where the left or right table is empty
Here’s an illustration of these types of JOINs:
PHP Lessons - Lesson 4 - Working with Images, GD2 Library
In the previous lessons, we learned how to write database queries, so now we'll focus less on writing queries and more on practicing them. We'll also combine writing queries with learning other PHP features, starting with image processing. In one of the previous lessons, we already uploaded files and even created a Files table for uploaded files. Now, let’s upload images to the same table. But first, we need to add a photo upload field to the content creation form.
PHP Lessons - Part 3 - Creating Your Own CMS
Creating websites on CMS platforms is not limited to Drupal, Joomla, and WordPress. In fact, most websites in the world are built on custom CMS solutions. Even though a lot of PHP code has already been written, developers often prefer to use their own tools. Let’s try to understand why you might want to build your own CMS.
1.1. Creating your own CMS. Introduction.
In this part of our course, we will focus on building our own CMS for an online store. But before we begin, you should read the introduction to understand whether you actually need to write your own CMS or simply use something like Drupal with the convenient Commerce module (and lots of ready-made modules). In the introduction, we will cover:
1.2. What will be in our CMS
After reviewing existing commerce sites, we need to define the functionality of our future CMS. Obviously, we need to allow users to find and view products in various categories. Users should be able to order these products by adding them to the cart and going through the checkout process, filling in order details to calculate shipping, payment, and taxes. We will also build an admin panel for managing orders and products. Below is a detailed list of all features:
Products
We need to implement the following functionality for products:
1.3. Building our PHP framework
There are many different ways to construct a framework. Some people prefer very complex frameworks, while others prefer very simple ones. In our articles, we’re going to quickly build a framework that is easy to use and easy to understand.
Our articles will help you develop your own framework, different from the one we’re building for an online store. You’ll be able to easily add other parts to the framework to create something bigger. The main goal of this article series is to teach you how to build your own framework for any CMS.
1.4. Let's start writing an MVC framework
We’ve described in enough detail what our framework should include, and now it’s time to implement it. First, you need a web server. You can try using Denwer, but you might need to upgrade PHP.
You can download Denwer with PHP 5.5.20 from this page:
https://drupalbook.org/ru/drupal/denwer-obnovlenie-php
or from GitHub:
1.5. Connecting classes for working with the database and templates
We’ve created a structure for our framework, and now it’s time to think about storing data: news, products. The object for working with the database should be able to:
- Manage the connection to the database
- Provide a lightweight abstraction over the database
- Cache queries
- Make common database operations easier
To do this, we will create the object at Registry/objects/db.class.php:
1.6. Products and categories - creating DB tables
Before creating product and category functionality, let’s think about the information our customers and site administrators will need. We must provide enough information about the product, including the product name, detailed description, and price. We may also display a product photo and additional images. The product weight may be needed to calculate shipping costs. We also need to track the quantity in stock to avoid selling out-of-stock items. For the site administrator, we'll need a product ID and a human-readable URL for search engines.
PHP language alphabet
The alphabet of a language refers to the set of all permissible characters that can be used in that language.
The PHP language alphabet includes the following characters:
Letters
Uppercase and lowercase Latin letters from A to z, as well as the underscore (_) character, which is also considered a letter. Uppercase and lowercase letters are interchangeable (case-insensitive);
Digits
Arabic digits: 0 1 2 3 4 5 6 7 8 9;
Single characters
Special single characters: + - ! * / = < > . , : ; $ #;