【问题标题】:How do I grab values from a row in a database using codeigniter?如何使用 codeigniter 从数据库中的一行中获取值?
【发布时间】:2015-12-23 06:08:40
【问题描述】:

所以我正在使用 codeigniter,目前正在尝试从表的一行中获取数据,我们将其称为表 A,并将该行中的值放入表 b 中。

我尝试使用以下方法:

$this->db->where('email', $this->session->userdata('email'));

$data = $this->db->get('table_A');

$this->db->insert('table_B', $data);

还有其他变体,但没有任何运气。 get() 方法不返回值吗?

感谢任何帮助。

谢谢。

【问题讨论】:

    标签: php mysql database codeigniter


    【解决方案1】:
    $data = $this->db->get('table_A');
    
    $newdata = array( 
    'USER_EMAIL ' => $data->row()->USER_EMAIL , 
    'USER_CLOCK_IN' => $data->row()->USER_CLOCK_IN 
    )
    
    $this->db->insert('table_B', $newdata);
    

    【讨论】:

    • 如果我想获得不止一列怎么办
    • 就像我上次回答的一样! $this->db->insert('table_B', $data->results());
    • 你应该先试试。
    • 好的。我问了下面的人同样的事情。你有'table_B_row'。如果表 B 为空且没有任何行怎么办
    • 你的表怎么没有行??
    猜你喜欢
    • 2013-09-19
    • 1970-01-01
    • 1970-01-01
    • 2019-05-07
    • 1970-01-01
    • 2013-05-06
    • 2014-07-17
    • 2023-03-27
    • 1970-01-01
    相关资源
    最近更新 更多