By default, migrations are applied to the same database specified by the db application component. If you want them to be applied to a different database, you may specify the db command-line option like shown below:
yii migrate --db=db2
yii migrate/history # showing the last 10 applied migrations
yii migrate/history 5 # showing the last 5 applied migrations
yii migrate/history all # showing all applied migrations
yii migrate/new # showing the first 10 new migrations
yii migrate/new 5 # showing the first 5 ...
yii migrate/mark 150101_185401 # using timestamp to specify the migration
yii migrate/mark "2015-01-01 18:54:01" # using a string that can be parsed by strtotime()
yii migrate/mark m150101_185401_create_news_table # using full name
yii migrate/mark 13...
yii migrate
This command will list all migrations that have not been applied so far. If you confirm that you want to apply these migrations, it will run the up() or safeUp() method in every new migration class, one after another, in the order of their timestamp values. If any of the migrations fa...
An abstract class is a class that cannot be instantiated. Abstract classes can define abstract methods, which are methods without any body, only a definition:
abstract class MyAbstractClass {
abstract public function doSomething($a, $b);
}
Abstract classes should be extended by a child cla...
SELECT *
FROM
table1,
table2
SELECT
table1.column1,
table1.column2,
table2.column1
FROM
table1,
table2
This is called cross product in SQL it is same as cross product in sets
These statements return the selected columns from multiple tables in one query....
Set memory limit and disable swap limit
docker run -it -m 300M --memory-swap -1 ubuntu:14.04 /bin/bash
Set both memory and swap limit. In this case, container can use 300M memory and 700M swap.
docker run -it -m 300M --memory-swap 1G ubuntu:14.04 /bin/bash
WCF tracing is built on top of System.Diagnostics. To use tracing, you should define trace sources in the configuration file or in code.
Tracing is not enabled by default. To activate tracing, you must create a trace listener and set a trace level other than "Off" for the selected trace s...
We can use Predefined Constants for Date format in date() instead of the conventional date format strings since PHP 5.1.0.
Predefined Date Format Constants Available
DATE_ATOM - Atom (2016-07-22T14:50:01+00:00)
DATE_COOKIE - HTTP Cookies (Friday, 22-Jul-16 14:50:01 UTC)
DATE_RSS - RSS (Fri, 22...
Installation Requirements
The minimum requirement by this project template is that your Web server supports PHP 5.4.0.
Yii2-advanced-app can be installed in two ways. They are
Installing via Composer
Installing from an Archive File
1) Installing via Composer
If you do not already have Comp...
A closure is an anonymous function that can't access outside scope.
When defining an anonymous function as such, you're creating a "namespace" for that function. It currently only has access to that namespace.
$externalVariable = "Hello";
$secondExternalVariable = "Foo&qu...
A std::vector can be useful for returning a dynamic number of variables of the same type. The following example uses int as data type, but a std::vector can hold any type that is trivially copyable:
#include <vector>
#include <iostream>
// the following function returns all integers...
Program units often make use of literal constants. These cover the obvious cases like
print *, "Hello", 1, 1.0
Except in one case, each literal constant is a scalar which has type, type parameters and value given by the syntax.
Integer literal constants are of the form
1
-1
-1_1 ...
A common pattern in C# is using bool TryParse(object input, out object value) to safely parse objects.
The out var declaration is a simple feature to improve readability. It allows a variable to be declared at the same time that is it passed as an out parameter.
A variable declared this way is sco...
The 0b prefix can be used to represent Binary literals.
Binary literals allow constructing numbers from zeroes and ones, which makes seeing which bits are set in the binary representation of a number much easier. This can be useful for working with binary flags.
The following are equivalent ways o...