小编use*_*886的帖子

如何使用CodeIgniter加载另一个数据库?

我有一个CodeIgniter和一些Mysql数据库.但是知道我想设置另一个数据库工作,并在一些操作后禁用它.例如,我有函数make_some_actions_with_db(),现在我需要有类似的东西:

public function action()
{
//load db
make_some_actions_with_db();
//disable db
}
Run Code Online (Sandbox Code Playgroud)

所以,现在我需要知道如何设置新的默认数据库以及如何设置另一个(第一个)数据库.谢谢.

更新: 它不起作用:

   public function update_record_insert_test()
    {
        if ($this->facebook->getUser())
        {
            $another_db_settings['hostname'] = 'localhost';
            $another_db_settings['username'] = 'root';
            $another_db_settings['password'] = '';
            $another_db_settings['database'] = 'name';
            $another_db_settings['dbdriver'] = "mysql";
            $another_db_settings['dbprefix'] = "";
            $another_db_settings['pconnect'] = TRUE;
            $another_db_settings['db_debug'] = TRUE;
            $another_db_settings['cache_on'] = FALSE;
            $another_db_settings['cachedir'] = "";
            $another_db_settings['char_set'] = "utf8";
            $another_db_settings['dbcollat'] = "utf8_general_ci";
            $this->load->database($another_db_settings);

            $_POST['id']='AccountPagesView.a_book/1000';
            $_POST['value']='test';
            $_POST['old_value']='not';
            $welcome=new Welcome();
            $welcome->update_record();
        }
        else
        {
            $url=$this->facebook->getLoginUrl(array('next' => base_url().'update_record_insert_test'));
            redirect($url);
        }
    }
Run Code Online (Sandbox Code Playgroud)

php codeigniter

5
推荐指数
1
解决办法
8858
查看次数

是否有可能改变定义常数的值?

可能重复:
更改先前定义的常量的值

有一个恒定的ABC,我需要得到它的价值,保存,改变,做一些行动和恢复.但我被告知这是不可能的.请告诉我,这是真的吗?如果不是,请告诉我,如何从常量中获取值并为其设置值?

php constants

5
推荐指数
1
解决办法
5915
查看次数

如何使用JS/Jquery清除div容器的内容?

我一直在开发一些页面,我需要清除一些div的内容:

                <table>
                    <tbody>
                    <div class="records_content">
                        <?php
                            $i=0;
                            foreach ($records as $record) {
                                echo "<tr class = 'output' style='border-bottom: 1px dotted silver;'>";
                                echo "<td width='400'>" . strip_tags($record['language_value']) . "</td>";
                                if ($record['approved_translation'])
                                {
                                    echo "<td width='200' height='30'><div class='field' id='".$record['label_value']."/".$record['language_id']."'>".
                                        strip_tags($record['approved_translation']['language_value'])."</div></td><td><button class='btn btn-info' id='{$record['label_value']}/{$record['language_id']}' href='#'>More...</button>"."</td>";
                                }
                                else
                                {
                                    echo "<td  width='200'>"."<div id='".$record['label_value']."/".$record['language_id']."'><span class='no_translate'>Not translated</span></div>" . "</td>";   
                                }                   
                                echo '</tr>';
                                $i++;
                            }
                        ?>
                    </div>
                    </tbody>
                </table> 
Run Code Online (Sandbox Code Playgroud)

一段JS代码:

           $(".page_button").click(function () {
                $.post("http://"+document.location.host+"/index.php/welcome/update_records_set/"+this.id,
                    function(data)
                    {
                        alert('123');
                        $(".records_content").empty();
                    });
            });
Run Code Online (Sandbox Code Playgroud)

该脚本有效,因为我看到“123”通知,但带有“.records_content”类的 div 容器不清楚。请告诉我,我该如何解决它?谢谢。

更新: 现在可以了。但我在分页方面遇到了一个新问题:

                <br><b>Page:</b><br/>
                <?php …
Run Code Online (Sandbox Code Playgroud)

javascript jquery

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

php ×2

codeigniter ×1

constants ×1

javascript ×1

jquery ×1