Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] can't save transaction without details
#31

[eluser]theprodigy[/eluser]
ok then, I guess $data[‘item’] = $this->Main_company_db->save($dt,$item); is correct
(it was just a guess anyway since I really don't know what models you are loading on what page)

what does the save() method look like in your main_company_db model?
#32

[eluser]maria clara[/eluser]
[quote author="theprodigy" date="1265371993"]ok then, I guess $data[‘item’] = $this->Main_company_db->save($dt,$item); is correct
(it was just a guess anyway since I really don't know what models you are loading on what page)

what does the save() method look like in your main_company_db model?[/quote]

here's my MODEL in main_company_db:

Code:
function save($data,$item)
    {
    
        if ($item=='')
            {
            $this->db->trans_start();
            $this->db->insert('maint_company', $data);
            $item = $this->db->insert_id();
            $this->db->trans_complete();                    
            }
        else
            {
            $this->db->trans_start();
            $this->db->where('company_id', $item);
            $this->db->update('maint_company', $data);        
            $this->db->trans_complete();
            }
            
        return $item;    
    }
#33

[eluser]theprodigy[/eluser]
ok, can you log into phpmyadmin (or whatever tool you use to administer your database, and run the following query, please.
Code:
SHOW CREATE TABLE maint_company
#34

[eluser]maria clara[/eluser]
the error is pointing me with this line:

Code:
$sec_exist = $this->sec_companyaccess_db->getDetails($dt);

i have change main_company_db to sec_companyaccess_db but still i have this error:

Quote:A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message: Undefined property: Sec_users::$sec_companyaccess_db</p>
<p>Filename: controllers/sec_users.php</p>
<p>Line Number: 536</p>

</div><br />
<b>Fatal error</b>: Call to a member function getDetails() on a non-object in <b>C:\xampp\htdocs\comunion\system\application\modules\sec_users\controllers\sec_users.php</b> on line <b>536</b><br />
#35

[eluser]maria clara[/eluser]
[quote author="theprodigy" date="1265372970"]ok, can you log into phpmyadmin (or whatever tool you use to administer your database, and run the following query, please.
Code:
SHOW CREATE TABLE maint_company
[/quote]

here i attached an image of my main_company_db table
#36

[eluser]theprodigy[/eluser]
[quote author="maria clara" date="1265372979"]the error is pointing me with this line:

Code:
$sec_exist = $this->sec_companyaccess_db->getDetails($dt);

i have change main_company_db to sec_companyaccess_db but still i have this error:

Quote:A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message: Undefined property: Sec_users::$sec_companyaccess_db</p>
<p>Filename: controllers/sec_users.php</p>
<p>Line Number: 536</p>

</div><br />
<b>Fatal error</b>: Call to a member function getDetails() on a non-object in <b>C:\xampp\htdocs\comunion\system\application\modules\sec_users\controllers\sec_users.php</b> on line <b>536</b><br />
[/quote]
Are you loading the model under this new name?
#37

[eluser]maria clara[/eluser]
im loading this model
Code:
$this->load->model('Users_db','User');

but when i use 'User' it shows me a database error because the company_code is not in the sec_users table. i have joined the maint_company table with sec_companyaccess because i am saving the company_code in the detail grid not in the master grid.

while the sec_users table saves the master grid..
#38

[eluser]theprodigy[/eluser]
if you aren't going to be using User, then don't load it. Load the other one (sec_companyaccess). And nothing is stopping you from loading both (if you need both in this controller).
#39

[eluser]maria clara[/eluser]
[quote author="theprodigy" date="1265374720"]if you aren't going to be using User, then don't load it. Load the other one (sec_companyaccess). And nothing is stopping you from loading both (if you need both in this controller).[/quote]

but i need to load also the 'User' for my master grid.

note: code for saving in the master grid;
Code:
elseif ($data['action']=='save')
        {
            $item = $this->input->post("item");    
            $dt['username'] = $this->input->post('username');
            $sec_exist = $this->User->getDetails($dt);
            
            if ($sec_exist && $item!=$sec_exist['user_id'])
            {
                $c .= 'User ID already exists.';
                $data['action'] = 'exist';
            }
            else
            {
                $fields = array(
                        "username"
                        ,"last_name"
                        ,"first_name"
                        ,"middle_initial"
                        ,"role_id"
                        ,"dept_id"                    
                        );
                
            foreach ($fields as $field)
            {
                if (isset($_POST[$field])) $dt[$field] = $this->input->post($field);
            }
            
            $item = $this->input->post("item");

and while the sec_companyaccess_db and the maint_company_db is for my detail grid..

here code for saving in the detail grid:

Code:
case $crudConfig['create']:
                $c = "";
                $id['company_code'] = $this->input->post('company_code');
                $sec_exist = $this->Main_company_db->getDetailList($id);
                
                if ($sec_exist)
                {
                    $c .= 'Company ID already exists.';
                    $data['action'] = 'exist';
                }
                else
                {
                $fields = array(
                        "company_code"
                        ,"company_name"
                        );
                
                foreach ($fields as $field)
                {if (isset($_POST[$field])) $id[$field] = $this->input->post($field);}

                $item = $this->input->post("item");        
                $data['item'] = $this->Main_company_db->save_detail($id,$item);
                }
                break;


how can i load two model in the same controller???
#40

[eluser]maria clara[/eluser]
i have tried this::

Code:
$this->load->model('Dataset_db');        
        $this->load->model('Users_db','User');
        $this->load->model('Main_company_db');

but it shows me this:


Quote:An Error Was Encountered

Unable to locate the model you have specified: main_company_db




Theme © iAndrew 2016 - Forum software by © MyBB