Welcome Guest, Not a member yet? Register   Sign In
Updating data on another DB - is that possible?
#1

[eluser]red2034[/eluser]
I understand how to change / update data on $this DB:

Code:
$this->db->where('class_id', $param2);
$this->db->update('class', $data);

But is it possible to update data on another DB on the same server????

Code:
$that->db->where('class_id', $param2);
$that->db->update('class', $data);


Do I need to 'load' that other DB in the loading portion? and if so how do I do that?
THANKS!
#2

[eluser]red2034[/eluser]
I found this forum thread....
http://ellislab.com/forums/viewthread/145901/
#3

[eluser]red2034[/eluser]
So now that I have access to multiple DBs (default, platform) this is what I would like to do:

Code:
public function index()
    {
  $course_id = '18896';
        if ($this->session->userdata('student_login') != 1)
            redirect(base_url() . 'index.php?login', 'refresh');
        if ($this->session->userdata('student_login') == 1)
$this->db_platform = $this->CI->load->database('platform', TRUE);  
$class_status = $this->db_platform->get_where('class' , array('status' => 'not attempted'))->row_array();
     $data['status'] = 'in-progress';
            
            $this->db_platform->update('status', $data);
   redirect(base_url() . 'index.php?student/dashboard', 'refresh');
  
    }

I am trying to change the 'status' data to 'in-progress' but it is not updating...

Anybody see my error?
#4

[eluser]CroNiX[/eluser]
Please just post one thread.
#5

[eluser]red2034[/eluser]
sorry - will do!

Do you see an error in the code above?
#6

[eluser]Karman de Lange[/eluser]
[quote author="red2034" date="1392487397"]So now that I have access to multiple DBs (default, platform) this is what I would like to do:

Code:
public function index()
    {
  $course_id = '18896';
        if ($this->session->userdata('student_login') != 1)
            redirect(base_url() . 'index.php?login', 'refresh');
        if ($this->session->userdata('student_login') == 1)
$this->db_platform = $this->CI->load->database('platform', TRUE);  
$class_status = $this->db_platform->get_where('class' , array('status' => 'not attempted'))->row_array();
     $data['status'] = 'in-progress';
            
            $this->db_platform->update('status', $data);
   redirect(base_url() . 'index.php?student/dashboard', 'refresh');
  
    }

I am trying to change the 'status' data to 'in-progress' but it is not updating...

Anybody see my error?[/quote]

This $this->db_platform->update('status', $data); will update all rows your status table to 'in-progress' , you need a where clause to limit it to 1 row (if that is the intention).

Are you getting any errors or what is the issue?

L:
#7

[eluser]red2034[/eluser]
I see your point: I have re-worked the code as such which keeps all the actions in the same DB:

view page code:
Code:
<a href="&lt;?php echo base_url();?&gt;;index.php?student/classes/launch/&lt;?php echo $row['class_id'];?&gt;" class="btn btn-gray btn-small">
                                    <;?php echo get_phrase('launch');?&gt;;
                                    </a>

and controller code:
Code:
if ($param1 == 'launch') {
        $class_info = $this->db->get_where('class' , array('class_id' => $param2))->row_array();
        $data['status'] = 'in-progress';
        $this->db->where('class_id', $param2);
        $this->db->update('class', $data);

        $class_link = $class_info['deep_link'];
        anchor($class_link, 'title="title"', array('target' => '_blank', 'class' => 'new_window'));
     }

this fixes the 'status' columns problem but it just opens the current page in the same window instead of opening $class_info['deep_link']; in a new window

Thanks for the help!
#8

[eluser]Karman de Lange[/eluser]
You don't have any code that will open anything in any new page?

anchor() is just a shortcut for <a></a> .. and simply returns the string. So you have to echo it somewhere and the user need to click on it, or you have to use javascript to open the new window (which most browsers will block by default).


Can you maybe give breakdown on what you trying to accomplish then maybe can help to improve get the logic right.

L:




Theme © iAndrew 2016 - Forum software by © MyBB