我正在寻找一种很好的方法来获得在Zend Studio for Eclipse中工作的codeigniter中的库的自动完成和点击引用(无论那个叫什么).
例如,如果我做$ this-> load-> library('dx_auth'); $这 - > dx_auth-> get_user_id();
zend工作室不知道它是什么..
有这种黑客的方式(见下文,来源),但我觉得应该有一个更好的方法来做到这一点..
有人有主意吗?
// All of these are added so I get real auto complete
// I don't have to worry about it causing any problems with deployment
// as this file never gets called as I'm in PHP5 mode
// Core CI libraries
$config = new CI_Config();
$db = new CI_DB_active_record();
$email = new CI_Email();
$form_validation = new CI_Form_validation();
$input = new CI_Input();
$load …Run Code Online (Sandbox Code Playgroud) 基本上我有一个表有几个标记为Unique的列.我有一个脚本,使用如下命令将一堆值转储到表中:
$this->db->query("INSERT INTO `table` (`col1`, `col2`, `col3`) VALUES (`val1`, `val2`, `val3`)");
Run Code Online (Sandbox Code Playgroud)
我的脚本经常会尝试插入违反其中一列唯一性的行.但是,我不想让脚本因数据库错误而中止,而是希望它继续,可能会输出一些消息.基本上我正在寻找相同的codeigniter
mysql_query("INSERT blah blah blah") or print("fail");
Run Code Online (Sandbox Code Playgroud)
谢谢!
马拉
在我的应用程序,我需要知道分配给数据库的配置项目,如什么样的价值观database,username等我如何获取这些信息?
需要有关codeigniter的帮助,我认为file_exists用于服务器路径,而不是用于url.但我的图像文件夹与应用程序和系统文件夹相同.在谷歌上找不到任何东西,请帮助
$url=base_url();
$filename="$url/upload/$id.jpg";
if (file_exists($filename)){
echo "<li><img src=\"".$url."upload/$id.jpg\" width=\"40\" height=\"40\" /></li>";
}else{
echo "<li><img src=\"http://www.mydomain.com/haha/image/noimg.png\" width=\"40\" height=\"40\" /></li>";
}
Run Code Online (Sandbox Code Playgroud) 好吧......凌晨2点,这是我划线的地方.帮助......在我的笔记本电脑最终走出窗外之前.:)
我已经尝试过使用setTimer,回调以及我能想到的其他一切(当然还有其他一些Stackoverflow提示).我已经删除了所有内容,所以我只留下基本代码.
我要做的是调用parseRow()并在最后保存记录之前,我需要获取相关的类别(通过AJAX); 然而,它吹过它,所以类别总是"未定义".
function parseRow(row){
var rowArray = row.trim().split(",");
var date = rowArray[0];
var checknum = rowArray[1];
var payee = rowArray[2];
var memo = rowArray[3];
var amount = rowArray[4];
//ERROR: blows right past this one and sets the category variable BEFORE ajax returns
var category = autoSelectCategory(payee);
saveRecord(date, checkNum, payee, memo, category, payment, deposit);
}
function autoSelectCategory(payee) {
var data;
$.ajax({
async: false,
url: "autoselectcategory",
dataType: "json",
data: {
string: payee
},
success: function (returnedData) {
data = returnedData; …Run Code Online (Sandbox Code Playgroud) 最近我开发了一个带有codeigniter的web应用程序.我在那里遇到了与会话相关的问题.
问题场景:
如果用户A登录到应用程序,则会话中设置用户ID.执行任务后,用户A关闭浏览器并离开计算机.不久之后,用户B来到并打开浏览器,看到应用程序处于登录状态.或者当用户B写下的URL,然后按Enter直接重定向到应用程序而无需使用前一交易日任何身份验证.
我使用以下配置进行会话:
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 1800;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = FALSE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
Run Code Online (Sandbox Code Playgroud)
现在我的问题是如何通过关闭codeigniter中的浏览器或浏览器选项卡来销毁所有会话?
我有几类,往往是通过运行var_dump或print_r.
在这些类中,我有一些变量,它们是对其他大型对象的引用,每个对象只有一个实例,并且只在类中使用(类外部有自己对这些类的引用)我不希望这些类打印在输出中,所以我声明它们private static工作正常.
但是Member has private access当我访问它时,我的IDE(PHPstorm)会弹出一个错误级别的警报self::$ci->...
我想知道这是否是IDE中的一个错误,突出显示因为它可能是一个错误(也就是它是静态的,但是类之外没有任何东西可以访问它,你为什么要这样做?),或者因为实际上存在语法上的错误用它?
作为示例,这里是类的一部分,注意,它=& get_instance();返回对Code Igniter超级对象的引用
private static $ci = null;
public function __construct(){
self::$ci = self::$ci =& get_instance();
}
public function product() {
if ($this->product == null) {
self::$ci->products->around($this->relative_date);
$this->product = self::$ci->products->get($this->product_id);
}
return $this->product;
}
Run Code Online (Sandbox Code Playgroud) 我有自己的工作经验,可以通过输入动态添加组织名称,部门名称,职位和持续时间.
<tr>
<td><span class="serial_no">1</span></td>
<td><input type="text" name="organization[]" size="50"/></td>
<td><input type="text" name="department[]" size="50"></td>
<td><input type="text" name="positions[]" size="40"></td>
<td><input type="text" name="duration[]"></td>
</tr>
Run Code Online (Sandbox Code Playgroud)
在CI中验证时,我执行了以下操作:
$organization = $this->input->post('organization');
$department = $this->input->post('department');
$positions = $this->input->post('positions');
$duration = $this->input->post('duration');
//printr($organization);
for($i = 0; $i < count($organization); $i++)
{
$org = $organization[$i];
$dept = $department[$i];
$pos = $positions[$i];
$dura = $duration[$i];
$this->form_validation->set_rules($org, "Organization", "trim|xss_clean|max_length[1]");
$this->form_validation->set_rules($dept, "Department", "trim|xss_clean|max_length[50]");
$this->form_validation->set_rules($pos, "Position", "trim|xss_clean|max_length[40]");
$this->form_validation->set_rules($dura, "Duration", "trim|xss_clean|integer");
}
Run Code Online (Sandbox Code Playgroud)
并显示错误:
<?php
echo form_error("organization[]");
echo form_error("department[]");
echo form_error("positions[]");
echo form_error("duration[]");
?>
Run Code Online (Sandbox Code Playgroud)
现在的问题是它不会将持续时间验证为整数.即使我放了一些随机的字母字符,它也不会显示错误.
当我验证如下: …
我发布这个以防万一其他人正在寻找相同的解决方案,因为我只是在这个废话上浪费了两天.
我有一个cron作业,使用以下代码每天使用一个非常大的文件更新数据库:
if (($handle = fopen(dirname(__FILE__) . '/uncompressed', "r")) !== FALSE)
{
while (($data = fgets($handle)) !== FALSE)
{
$thisline = json_decode($data, true);
$this->regen($thisline);
}
fclose($handle);
}
Run Code Online (Sandbox Code Playgroud)
这是一个仅用于cron作业的Codeigniter控制器.$ this-> regen函数运行一系列不同的检查,并存储数据库中该行的正确信息.该文件本身是由换行符分隔的超过300MB的JSON.
问题是:在整个内存耗尽之前,它只会处理大约20,000行.
我使用旧版本的Codeigniter框架.随着新版本的PHP我得到这个错误:
Only variables should be assigned by reference
我想知道这是否是安全的错误修正:更改:
$this->_base_classes =& is_loaded();
Run Code Online (Sandbox Code Playgroud)
至
$assign = is_loaded();
$this->_base_classes =& $assign;
Run Code Online (Sandbox Code Playgroud)
那是一样的吗?
codeigniter ×10
php ×4
database ×2
activerecord ×1
autocomplete ×1
file ×1
javascript ×1
jquery ×1
memory ×1
path ×1
session ×1
sql ×1
static ×1
validation ×1
zend-studio ×1