
In MySQL Workbench alter table there have 7 column flags available: PK, NN, UQ, BIN, UN, ZF and AI.
Posted by
chevrons in
MySQL

Just now I wrote PHPUnit test case to try get the url parameter with Selenium. In PHP use
$_GET function, you can get all the URL parameter. But it doesn’t work in PHPUnit with Selenium.
To solve it was simple, used “
$this->getLocation()” function to get current url and then used
PHP “parse_url()” and “parse_str()” to get the parameter.

My application always need get first and last month of the date when user given a date to my system. it look like very trouble but actually quite easy only.
From here I show you how to get first and last of the date in current month.
//last day of the month
date("Y-m-t");
//first day of the month
date("Y-m-1");
Why using
t in last day of the month, it is because in PHP date function “
t” will return you
Number of days in the given month.
And now we try get first and last date of the month from the last month.
Posted by
chevrons in
PHP

Because sometimes need to know last day of the previous month, and I was using procedure/routine to completed the query. That’s the reason I can’t use others programming language to do it. All the thing must finish in MySQL server only.
And very lucky, MySQL have “
last_day()” function to get last day of the month.
Below example are showing how to use it.
Posted by
chevrons in
MySQL

Recently I reinstall MySQL Database because it suddenly cannot start and it crash. After I successful reinstall, I found an extra database in MySQL Server.
When I tried to drop the database, I received the following error:
“Can’t drop database ‘dbname’; database doesn’t exist”
And when I tried to create a new database with same name, it told me:
“Can’t create database ‘dbname’; database exists”
That just didn’t make any sense! And the PHPMyAdmin application still listed the database in the Catalog list.
Posted by
chevrons in
MySQL

I’m working through ASP.NET MVC4 tutorial and the section “Accessing Your Model’s Data from a Controller”. I’ve attempted to add the MoviesController but the combo boxes for Model Class and Data context class do not list the Movie selections that they specified.
It is because I not yet rebuild the application and the tutorial also didn’t mention this.

Because need develop an APi application with frontend and backend together.
Frontend without any interface and it just return
JSON format to the user. But backend have interface to let user do the setting and update data.
In Yii
main.php only allow set one error page. The solution is set the error page in controller class.
You can follow
below example to write your own error page to each controller.
Posted by
chevrons in
Yii

Default Yii cgridview pagination didn’t show the first and last page. But actually it was hidden but the CSS class, the easy method is change the CSS class to let it can show it.

how to do it? open
pager.css file and find the code like below.
Controller error handler:
ul.yiiPager .first, ul.yiiPager .last {
display: none;
}
Posted by
chevrons in
Yii

If you install a CentOS server, but accidently also installed Desktop Environment such as GDM, GNOME or X Window, you can easily remove the GUI packages and return back to Command Line (CLI).
There are two ways to do that. You can simply disable GUI or completely uninstall it. I will provide steps to do both.
Temporary Disable GUI (GDM)
Open
inittab with nano
nano /etc/inittab
change
id:5:initdefault:
to
id:3:initdefault:
Remove GUI
Posted by
chevrons in
Linux

Sometimes we keep all the records/logs in one table. But if we want retrieve each group last records in one SQL it look like impossible.
Below Example showed how to:
SELECT rs1.*
FROM TABLE rs1 LEFT JOIN TABLE rs2
ON (rs1.name = rs2.name AND rs1.id < rs2.id)
WHERE rs2.id IS NULL;
Above method can get the last record results group by name.
If you want retrieve first records in each group, just change to
Posted by
chevrons in
MySQL