We can create table for mysql through query for php and wordpress
as
just for simple php we can write code to create the table in mysql as
$sql = "CREATE TABLE IF NOT EXISTS `social` (
`id` int(11) unsigned NOT NULL auto_increment,
`userid` int(11) NOT NULL default '0',
`type` varchar(500) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
mysql_query($sql);
through this lines of code we can create the DATABASE table
and for wordpress we will add the two line more as
$sql = "CREATE TABLE IF NOT EXISTS `social` (
`id` int(11) unsigned NOT NULL auto_increment,
`userid` int(11) NOT NULL default '0',
`type` varchar(500) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql);
as
just for simple php we can write code to create the table in mysql as
$sql = "CREATE TABLE IF NOT EXISTS `social` (
`id` int(11) unsigned NOT NULL auto_increment,
`userid` int(11) NOT NULL default '0',
`type` varchar(500) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
mysql_query($sql);
through this lines of code we can create the DATABASE table
and for wordpress we will add the two line more as
$sql = "CREATE TABLE IF NOT EXISTS `social` (
`id` int(11) unsigned NOT NULL auto_increment,
`userid` int(11) NOT NULL default '0',
`type` varchar(500) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql);
No comments:
Post a Comment