草庐IT

CodeIgniter-combobox

全部标签

php - 如何在 CodeIgniter 中使用 PHPUnit?

我阅读并阅读了有关PHPUnit、SimpleTest和其他单元测试框架的文章。他们都听起来太棒了!感谢https://bitbucket.org/kenjis/my-ciunit/overview,我终于让PHPUnit与Codeigniter一起工作现在我的问题是,我该如何使用它?我看到的每个教程都有一些抽象用法,例如assertEquals(2,1+1)或者:publicfunctiontestSpeakWithParams(){$hello=newSayHello('Marco');$this->assertEquals("HelloMarco!",$hello->speak(

php - Codeigniter : Why assign it to a variable? 中的 get_instance()

在Codeigniter中,get_instance()是一个全局可用的函数,它返回包含所有当前加载的类的Controller超对象(它返回Controller类实例)。我将包含当前的源代码:get_instance()在Codeigniter.php中定义//LoadthebasecontrollerclassrequireBASEPATH.'core/Controller.php';function&get_instance(){returnCI_Controller::get_instance();}还有CI_Controller在Controller.php中定义classCI

php - CodeIgniter - 如何捕获数据库错误?

有没有办法让CI在遇到DB错误时抛出exception而不是显示如下消息:ADatabaseErrorOccurredErrorNumber:1054Unknowncolumn'foo'in'whereclause'SELECT*FROM(FooBar)WHEREfoo='1'注意:我只希望这发生在一个Controller中。在其他Controller中,我很高兴它能够显示DB错误消息。 最佳答案 使用error()方法:$this->db->error();对于CodeIgniter2,您可以使用以下现已弃用的函数:$this->

php - base_url() 函数在 codeigniter 中不起作用

在我的web应用程序中使用codeigniter。我正在尝试使用base_url()函数,但它显示空结果。我也通过自动加载文件使用了自动加载助手,但它似乎也不起作用。我也定义了基本常量,但都是徒劳的。/css/template/default.css"type="text/css"/>//';//]]> 最佳答案 为了使用base_url(),您必须首先加载URLHelper。这可以在application/config/autoload.php(在第67行或附近)中完成:$autoload['helper']=array('url

php - CodeIgniter 中 pconnect 选项的优点/缺点

CodeIgniter数据库配置中的参数之一如下['pconnect']TRUE/FALSE-Whethertouseapersistentconnection您建议我将其设置为什么?如果我将其设置为FALSE,是否会对性能造成重大影响?将其设置为TRUE可能会出现哪些潜在问题? 最佳答案 只需查找持久连接的一般最佳做法即可。我的建议。默认情况下,不要如果您有:生产中的专用网络服务器和数据库硬件并已正确调整网络服务器和数据库并拥有准确的类似生产的测试环境并且仍然认为你的性能问题是由数据库连接时间引起的,考虑开启它持久连接会导致由于某

php - 使用 CodeIgniter 的 Active Record 将 NOW() 插入数据库

我想在Codeigniter的事件记录中使用mySQL函数NOW()在数据库中插入当前时间。以下查询无效:$data=array('name'=>$name,'email'=>$email,'time'=>NOW());$this->db->insert('mytable',$data);这是因为CodeIgniter的ActiveRecord类会自动转义输入。以下工作正常,通过调用set()并传递peratmeterFALSE,这样它就不会逃脱NOW()。$data=array('name'=>$name,'email'=>$email,);$this->db->set('time'

Codeigniter - 没有指定输入文件

我是Codeigniter的初学者,我看过一个CI教程,只是想做一件简单的事情。我下载了CI并将这个文件添加到Controller目录,但它不起作用。当我尝试使用http://..../index.php/site访问它时我得到输出......“没有指定输入文件”......顺便说一句,我将文件命名为site.php 最佳答案 只需在.htaccess文件中的index.php之后添加?符号即可:RewriteEngineonRewriteBase/RewriteCond%{REQUEST_FILENAME}!-fRewriteCo

php - 如何删除 codeigniter 路径中的 "index.php"

如何删除"index.php"在中心某处的codeigniter的每个路径中突出?我想要干净的非index.php-fiedURLs? 最佳答案 如果您使用的是Apache,请在您的Web根目录中放置一个.htaccess文件,其中包含以下内容:RewriteEngineonRewriteCond$1!^(index\.php|[Javascript/CSS/ImagerootFoldername(s)]|robots\.txt)RewriteRule^(.*)$/index.php/$1[L]另一个不错的版本在这里:http://

php - CodeIgniter 从 url 中删除 index.php

我当前的网址如下所示[mysite]index.php/[restoftheslug]。我想从这些网址中删除index.php。mod_rewrite在我的apache2服务器上启用。在config中,$config['index_page']='';我的codeignitor根.htaccess文件包含,RewriteEngineonRewriteCond%{REQUEST_FILENAME}!-fRewriteCond%{REQUEST_FILENAME}!-dRewriteRule.*index.php/$0[PT,L]但它仍然无法正常工作。我哪里错了?

php - CodeIgniter activerecord,检索最后一个插入ID?

是否有任何选项可以在CodeIgniter中获取新记录的最后插入id?$last_id=$this->db->insert('tablename',array('firstcolumn'=>'value','secondcolumn'=>'value'));考虑到表格由字段id(自动增量)firstcolumn和secondcolumn组成。这样就可以在下面的代码中使用插入id了。 最佳答案 真丢脸……我看了userguide第一个函数是$this->db->insert_id();这也适用于activerecord插入...编辑: