{"id":1024,"date":"2015-05-14T08:31:42","date_gmt":"2015-05-14T08:31:42","guid":{"rendered":"http:\/\/tw.newtonstudio.com\/?p=1024"},"modified":"2015-05-14T08:33:28","modified_gmt":"2015-05-14T08:33:28","slug":"ci-sqlserver","status":"publish","type":"post","link":"http:\/\/tw.newtonstudio.com\/?p=1024","title":{"rendered":"CI + SQLSERVER"},"content":{"rendered":"<p>install PHP DLL first:<br \/>\nhttps:\/\/msdn.microsoft.com\/en-us\/library\/cc296170(v=sql.105).aspx<\/p>\n<p>CodeIgnitor: 2.2<br \/>\nSQL SERVER: SQL SERVER 2008 R2<br \/>\nPHP: 5.4<br \/>\nWeb Server: Apache<\/p>\n<pre>\r\n\r\n\/application\/config\/database.php\r\n$db['default']['hostname'] = '.\\SQLEXPRESS';\r\n$db['default']['username'] = 'sa';\r\n$db['default']['password'] = 'XXXXXXX';\r\n$db['default']['database'] = 'YYYYYYY';\r\n$db['default']['dbdriver'] = 'sqlsrv';\r\n$db['default']['dbprefix'] = '';\r\n$db['default']['pconnect'] = FALSE;\r\n$db['default']['db_debug'] = TRUE;\r\n$db['default']['cache_on'] = FALSE;\r\n$db['default']['cachedir'] = '';\r\n$db['default']['char_set'] = 'utf8';\r\n$db['default']['dbcollat'] = 'utf8_general_ci';\r\n$db['default']['swap_pre'] = '';\r\n$db['default']['autoinit'] = TRUE;\r\n$db['default']['stricton'] = FALSE;\r\n\r\n<\/pre>\n<p>\/\/system\/database\/drivers\/sqlsrv\/sqlsrv_driver.php<br \/>\nLINE 121 &#8211; 124<\/p>\n<pre>\r\nfunction db_select()\r\n{\r\nreturn $this-&gt;_execute('USE [' . $this-&gt;database.']');\r\n}\r\n<\/pre>\n<p>\/\/application\/models\/brand_model.php (testing model)<\/p>\n<pre>\r\nclass Brand_model extends CI_Model {\r\nprivate $table_name = \"\";\r\n\r\npublic function __construct() {\r\n$this-&gt;load-&gt;database();\r\n$this-&gt;table_name = \"[Brand]\";\r\n}\r\n\r\npublic function get(){\r\n\r\n$query = $this-&gt;db-&gt;get($this-&gt;table_name);\r\nreturn $query-&gt;result_array();\r\n\r\n}\r\n\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>install PHP DLL first: https:\/\/msdn.microsoft.com\/en-us [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[233,234],"class_list":["post-1024","post","type-post","status-publish","format-standard","hentry","category-php-","tag-ci","tag-sqlserver"],"_links":{"self":[{"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=\/wp\/v2\/posts\/1024","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1024"}],"version-history":[{"count":3,"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=\/wp\/v2\/posts\/1024\/revisions"}],"predecessor-version":[{"id":1028,"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=\/wp\/v2\/posts\/1024\/revisions\/1028"}],"wp:attachment":[{"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1024"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}