Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter and MSSQL uniqueidentifier issue
#1

[eluser]bigg-media[/eluser]
Probably a simple issue, but I can't seem to figure it out.

I have a small desktop with ubuntu 8.04 Server installed on it, running Apache2, PHP5 with sybase support enabled and I am having an issue.

I am interfacing with an MSCRM MSSQL server. The way CRM does everything the Primary key for every table is uniqueidentifier. I am connecting to the database just fine. I can run simple queries just fine. However if I try to use a uniqueidentifier to join tables, or pass it to another query or even print the uniqueidentifier to screen it comes through as gobbledy-gook.

MODEL: contact.php
Code:
function GetCustomerId($ScriptingContactId)
{
    $this->db->select('AccountBase.ParentAccountId');
    $this->db->from('New_ProjectExtensionBase');
    #$this->db->join('New_ProjectBase','New_ProjectExtensionBase.New_ProjectId=New_ProjectBase.New_ProjectId','left');
    $this->db->join('AccountBase','New_ProjectExtensionBase.New_AccountId=AccountBase.AccountId','left');
    #$this->db->join('AccountExtensionBase','New_ProjectExtensionBase.New_AccountId=AccountExtensionBase.AccountId','left');
    $this->db->where('New_ProjectExtensionBase.New_ScriptingContactId',$ScriptingContactId);
    $query = $this->db->get();
    $row = $query->row();
    
    return $row->ParentAccountId;
}

CONTROLLER: content.php
Code:
<?
class Content extends Controller {

    function Content()
    {    
        parent::Controller();
        $this->load->model('account');
        $this->load->model('project');
        $this->load->model('contact');
        $this->load->model('paragraph');
        $this->load->model('production');
        $this->load->model('calendar');
        #$this->userid = $this->session->userdata('ContactId');
        $this->userid = '{61463116-58AA-DC11-AF0F-0019B9CCA70F}';
    }
        
    function index()
    {
        redirect('content/overview');
    }
    
    function overview()
    {
        #$this->auth->check();
        $data['page'] = 'overview';
        $data['page_title'] = 'Account Overview';
        $data['customerid'] = $this->contact->GetCustomerId($this->userid);
        #print_r($data['customerid']);
        #$data['customer'] = $this->account->Location($this->contact->GetCustomerId($this->userid));
        #$data['projects'] = $this->project->GetProjects($this->userid);
        #print $this->userid;
        print_r($data);
        #$this->load->vars($data);
        #$this->load->view($this->config->item('default_template_dir').'template/container');
    }
Basically the only query running is the contact->GetCustomerId

Here is the output:
Array ( [page] => overview [page_title] => Account Overview [customerid] => >#Q4��#ܯ##�̧# )

I am thinking maybe it is a setting on this new server, since I have also noticed when I print out contents from the database on another project on this server, the quotes are showing those funky characters.

I am open to any and all suggestions. I have a workaround right now, in that my MSSQL database is synced to a MySQL db once a a day to house the information, but would really like to get this working tapping straight into MSSQL.

Thanks,
Brent
#2

[eluser]gtech[/eluser]
Have you dried doing the following directly with MYSQL shell
Code:
select accountid from New_ProjectExtensionBase where New_ScriptingContactId = '<scid>';
select customerid from accountbase where accountid = '<accountid>';

Then you can narrow down if it is a CI problem or not.




Theme © iAndrew 2016 - Forum software by © MyBB