CodeIgniter Forums
how to create ci_sessions table in ms sql server same - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: how to create ci_sessions table in ms sql server same (/thread-49826.html)



how to create ci_sessions table in ms sql server same - El Forum - 03-05-2012

[eluser]sunil shrestha[/eluser]
I am novice to mssql server and I have to create Sql query for mssql server for creating the ci_sessions table same as table sql query provided in the CI user guide which is given in the mysql as below:
Code:
CREATE TABLE IF NOT EXISTS  `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(16) DEFAULT '0' NOT NULL,
user_agent varchar(120) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id),
KEY `last_activity_idx` (`last_activity`)
);

And also for Captcha table that I have to convert to MSSQL query. MySQL query is:
Code:
CREATE TABLE captcha (
captcha_id bigint(13) unsigned NOT NULL auto_increment,
captcha_time int(10) unsigned NOT NULL,
ip_address varchar(16) default '0' NOT NULL,
word varchar(20) NOT NULL,
PRIMARY KEY `captcha_id` (`captcha_id`),
KEY `word` (`word`)
);

Here, I am trying to connect the codeigniter to mssql server using odbc connection. All is working fine but when problem in creating session that should be stored in database due to wrong design of ci_sessions table. Plz help


how to create ci_sessions table in ms sql server same - El Forum - 03-05-2012

[eluser]sunil shrestha[/eluser]
[quote author="sunil shrestha" date="1330933112"]I am novice to mssql server and I have to create Sql query for mssql server for creating the ci_sessions table same as table sql query provided in the CI user guide which is given in the mysql as below:
Code:
CREATE TABLE IF NOT EXISTS  `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(16) DEFAULT '0' NOT NULL,
user_agent varchar(120) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id),
KEY `last_activity_idx` (`last_activity`)
);

And also for Captcha table that I have to convert to MSSQL query. MySQL query is:
Code:
CREATE TABLE captcha (
captcha_id bigint(13) unsigned NOT NULL auto_increment,
captcha_time int(10) unsigned NOT NULL,
ip_address varchar(16) default '0' NOT NULL,
word varchar(20) NOT NULL,
PRIMARY KEY `captcha_id` (`captcha_id`),
KEY `word` (`word`)
);

Here, I am trying to connect the codeigniter to mssql server using odbc connection. All is working fine but when problem in creating session that should be stored in database due to wrong design of ci_sessions table. Plz help[/quote]


how to create ci_sessions table in ms sql server same - El Forum - 04-16-2012

[eluser]C.T.[/eluser]
Try this in M$ SMS, hope it help

Code:
USE CI_Database
GO

/*
20120309
CodeIgniter Session Database
Author Cusco
*/

CREATE TABLE CI_Sessions (
session_id NVARCHAR(40) DEFAULT '0' NOT NULL,
ip_address NVARCHAR(16) DEFAULT '0' NOT NULL,
user_agent NVARCHAR(120) NOT NULL,
last_activity INT DEFAULT 0 NOT NULL,
user_data NTEXT NOT NULL,
CONSTRAINT  PK_CI_Session PRIMARY KEY (session_id ASC)
)
GO

CREATE NONCLUSTERED INDEX NCI_Session_Activity
ON CI_Sessions(last_activity DESC)
GO


P.S. I think M$SQL dont have "unsigned" datatype correct me if I am wrong