⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

SQL Server



php_lover
  • profile picture
  • Member

Posted 12 March 2013 - 04:47 AM

IS grocery crud working with SQL Server 2008 and my second question is this possible that i coneect same grocerry crud with both Database SQL Server 2008 as well as mysql

coz i want to fetch some data from SQL Server and some data from mysql

 


sachin vairagi
  • profile picture
  • Member

Posted 12 March 2013 - 06:02 AM

hi  php_lover, you can try this :-

 

 


 


1. In application/config/database.php, put this lines


 


$db['mssql']['hostname'] = 'hostname';

$db['mssql']['username'] = 'username';

$db['mssql']['password'] = 'password';

$db['mssql']['database'] = 'db_name';

$db['mssql']['dbdriver'] = 'mssql';

$db['mssql']['dbprefix'] = '';

$db['mssql']['pconnect'] = TRUE;

$db['mssql']['db_debug'] = TRUE;

$db['mssql']['cache_on'] = FALSE;

$db['mssql']['cachedir'] = '';

$db['mssql']['char_set'] = 'utf8';

$db['mssql']['dbcollat'] = 'utf8_general_ci';

$db['mssql']['swap_pre'] = '';

$db['mssql']['autoinit'] = TRUE;

$db['mssql']['stricton'] = FALSE;


 


 


2. in your model


 


    function __construct()

    {


        $this->mssql = $this->load->database('mssql', TRUE);

        parent::__construct();

 

    }


 


3. your query will be as follows


 


function get_data()


{


         $query=$this->mssql->select('*');

         $query=$this->mssql->from($table);

         $query=$this->mssql->where($where);

         $query=$this->mssql->order_by($orderby,'ASC');

         $query=$this->mssql->get();


 


        if ($query->num_rows() > 0) {

                foreach ($query->result() as $row) {

                    $data[] = $row;

                }

                return $data;

            }

            

            return false;


}
 
 


php_lover
  • profile picture
  • Member

Posted 12 March 2013 - 10:13 AM

Thanks @Sachin101  my friend i love India


Wibi Wiblink
  • profile picture
  • Member

Posted 04 February 2014 - 09:55 AM

but how do i render from the sql server? i used mysql & mssql. mysql running render like ussual.

 

$crud->set_table('tbl');
$crud->columns('col1','col2','col3','col4');
$crud->set_subject('blabla');
$output = $crud->render();

 

but how in mssql?

 

thank's before