In the previous note, we learned how to write simple queries to the database using Doctrine. But often we have to write something more kinky, with these joins of yours =). Here we will try to understand how it's done.
Today I came across an unpleasant problem - when using block layout, I needed to stretch a block to fill the empty space of the parent element vertically (div expand). Naturally, there is no difficulty in doing this horizontally - simply set the display to block and it will work =).
So, we already know theoretically (here you can read), why Doctrine, what advantages it provides compared to "bare" sql queries. Now we move on to practice.
When studying a new framework or web programming language, you may sometimes feel confused and ask yourself: When can I consider that I have learned the product to a decent level? When can I say that I know it, and if there are some things I don't know, I can quickly grasp/read them in the manual/search for them on Google?
Sometimes you need to convert the table engine MySQL in an existing database.
For example, I needed to create relationships between tables. To create them, the tables must be InnoDB (to support foreign keys).
Old Wordpress (and other) projects use MyISAM because until version MySQL 5.5.4 it was the default engine. But it doesn't support many useful features, such as foreign keys, transactions, etc. All these features are supported by the more modern engine InnoDB, which is now used by default.
After reading this article, you will be able to create relations in MySQL database using phpmyadmin. If for some reasons you don't want to use phpmyadmin, please look at SQL queries below.
So, what reason to store relations in the database? After all, your application also solves this task. Actually, it's all about the restrictions and actions upon changes, which can be set using relations.
For example, you can deny deleting category while any article connected with it. Or remove all articles if category removed. Or set NULL in relation field. In any case, using relations increases fault tolerance and reliability of the application.
You need to use an InnoDB engine to create a relation. Only this engine supports foreign keys. If you have MyISAM tables, you can read how convert it to InnoDB.
So, in the previous lesson we learned how to use the Twig template engine in the Symfony framework. Now we know how to write a simple template. But we don't know how to include external components (stylesheets, js, images), as well as create links to our own pages.
To create a form using tables, even a beginner webmaster can do it, but for formatting a tableless form, some skills are required. Let's consider a simple example, such as a login form.
Using templates in Symfony framework can be done in several ways. First, you can use PHP templates. But the preferred option is to use the Twig template engine (by default). Twig is a compiling open-source template engine written in PHP. It produces PHP/HTML code as output. Besides being very functional, Twig is also very fast.
Previously, we learned to use the QwtPlotSpectrocurve component (here). Qwt provides an alternative component that is more convenient for visualizing analytical functions. In this note, we will learn how to use QwtPlotSpectrogram.
During the work with Symfony framework, I received the following warning:
Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /var/www/symfony/app/cache/prod/classes.php on line 5009
In fact, there is nothing to worry about or unusual - this was caused by updating PHP to version 5.4, and since the new version was installed next to the old one with new configs, it was necessary to configure the PHP timezone in php.ini again. First, we need to find out which timezone we are in. More precisely, how it should be specified in the PHP config.
After learning how to create controllers (here), it is important to understand how a user can invoke a controller and how to work with it.
The Symfony framework has a special feature called routing system. In yii framework , for example, routing is determined by the file structure of the application by default (although you can still use a routing system with the necessary tools). However, in Symfony framework, you have to define the routing manually (excluding the basic routing created by the bundle generator).