William Jiang

JavaScript,PHP,Node,Perl,LAMP Web Developer – http://williamjxj.com; https://github.com/williamjxj?tab=repositories

3 tips from work.

1.
Issue: How to customize only input(type=”text”)’s width?
Solution: use input[type=”text”]

The following is a quick way to customize the input button’s width (the input type is only “text”, NOT “radio”, “checkbox”, “submit”, “reset” etc.)


input[type="text"] {
  width: 350px;
}

Since the apps scatter in different html templates, so modifying css is the only way. Adding the above codes into css file will make all apps change <input/> appearances immediately.

2. Mysql table definition

The following is a little complex MySQL table:


create table group1_group2 (
	upid int unsigned not null AUTO_INCREMENT,
	uid int(10) unsigned not null,
    ...,
	created timestamp not null default current_timestamp,
	primary key(upid),
	index (uid, pid),
	foreign key(uid) references users(uid)	on delete cascade,
	foreign key(pid) references projects(pid) on delete cascade
);
--
CREATE TABLE `test` (
  `uid` int(10) unsigned NOT NULL,
  `pid` tinyint not null,
  `username` varchar(30) NOT NULL,
  ...,
  `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  unique index(uid),
  index (pid),
  foreign key (username) references others(username) 
    on delete cascade on update cascade
)ENGINE = InnoDB;

The on delete cascade on update cascade act as a trigger.
Does Pear’s MDB2 totally support MySQL powerful syntax ?

3. Draw MySQL Schemas

phpMyAdmin brings with a simple tool to draw Database Structure.
Select the Database, then choose ‘Designer’ tab on the top tabs: the total Database Structure are displayed! Quite cool.
By using FF’s FireShot to process the graphic and immediately generate the Database Schema documents.

It seems ‘MySQL Workbench’ and DB Schema Viewer plugin for EClipse also have such functionality. But didn’t use yet.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: