这是我的CodeIgniter模型中的Database_update_entry函数,它在成功提交表单后执行.
<?php
function update_entry(){
$data = array(
'sl' => $this->input->post('item_sl'),
'item_name' => $this->input->post('item_name'),
'img_url' => $this->input->post('img_url'),
'sound_url' => $this->input->post('sound_url'),
'price' => $this->input->post('price'),
'unit' => $this->input->post('unit'),
'timestamp' => time(),
);
echo "current time: ". time();
$this->db->update(MY_TABLE_NAME, $data);
}
?>
Run Code Online (Sandbox Code Playgroud)
数据库查询执行得很好....但是设置到mysql表中的时间是
00:00:00,而<?php echo time() ?>语句在浏览器中显示1307018223 ....这是一个有效的UNIX时间戳. ..你可以在这里检查时间戳的有效性.
这是在成功更新update_query之后从mySQL表中获取数据的表的屏幕截图http://s3.amazonaws.com/awesome_screenshot/658523?AWSAccessKeyId=0R7FMW7AXRVCYMAPTPR2&Expires=1307020816&Signature=AncPjnzG9p9QT7zebZp7c9teB0%3D
我究竟做错了什么???我怎样才能将法律时间戳从我的php传递给mySQL? [ps我已经检查过mysql表中的时间戳字段是时间戳字段]
我在MAMP上安装了Codeigniter和Ion Auth.我有库工作,但我不知道如何为Ion Auth构建所需的数据库表.这样做是否有首选/最佳实践方式?我应该从某个地方复制查询代码吗?运行setup-db脚本?就此而言,安装了Codeigniter,是否应该执行任何基本的数据库设置?我所做的就是设置ci_sessions表.
谢谢你的帮助.
我只是看着CodeIgniter源代码,我遇到了一些我似乎无法弄清楚的事情; 我不确定它们是什么意思,因为它们大多像一两个符号,所以很难在谷歌和stackoverflow上搜索它们.
我遇到的一件事是:
$this->config =& get_config();
Run Code Online (Sandbox Code Playgroud)
我之前从未真正遇到过PHP =&(或大多数情况下&).这究竟是什么意思?难道他们分配的一个实例get_config来$this->config?我假设它$this->config来自文件顶部的声明var $config = array();
我去寻找get_config()功能,我找到了以下行:
function &get_config($replace = array())
Run Code Online (Sandbox Code Playgroud)
在这里,我的问题几乎是一样的:&代表什么,它做了什么?我在CI核心文件中看到了这两件事(&和=&).
我想知道的是他们评论的"风格".每个函数都以注释块开头,这是一个例子:
/**
* Set HTTP Status Header
*
* @access public
* @param int the status code
* @param string
* @return void
*/
Run Code Online (Sandbox Code Playgroud)
这是由一些插件或库生成的吗?手动执行此操作听起来很麻烦.我没有检查过像PHPDoc这样的东西,但这可能类似(或PHPDoc)吗?它似乎有用,如果它自动生成?嘻嘻.
在下一个问题上.我看到以下划线为前缀的不同功能.有明显的,__construct但也有功能_set_default_controller();和_set_routing();这些下划线有任何特殊意义吗?我知道双下划线用于称为"魔术方法"的东西(我正在思考__get,__set因为那些是我自己使用过的).他们有任何"特殊"的技术含义还是纯粹的语义?如果可能的话,启发我.
最后但并非最不重要的是,在控制器核心文件中,我看到了:
class CI_Controller {
private static $instance;
public function …Run Code Online (Sandbox Code Playgroud) 我在通过Codeigniter中的电子邮件类发送的电子邮件中遇到问题,在电子邮件中显示源HTML代码而不是呈现的HTML视图.为了进行测试,我目前在Windows上使用XAMPP上的CI,并使用Gmail SMTP发送到同一个Gmail地址.
发送电子邮件的功能如下:
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'myaccountname@gmail.com',
'smtp_pass' => 'mygmailpassword',
);
$this->load->library('email', $config);
$this->email->from($this->config->item('webmaster_email', 'tank_auth'), $this->config->item('website_name', 'tank_auth'));
$this->email->reply_to($this->config->item('webmaster_email', 'tank_auth'), $this->config->item('website_name', 'tank_auth'));
$this->email->to($email);
$this->email->subject(sprintf($this->lang->line('auth_subject_'.$type), $this->config->item('website_name', 'tank_auth')));
$this->email->message($this->load->view('email/'.$type.'-html', $data, TRUE));
$this->email->set_alt_message($this->load->view('email/'.$type.'-txt', $data, TRUE));
$this->email->set_newline("\r\n"); // require this, otherwise sending via gmail times out
$this->email->send();
Run Code Online (Sandbox Code Playgroud)
获取文本版本没有问题.加载的视图是一个将通过电子邮件发送出去的html文件.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title>Welcome to <?php echo $site_name; ?>!</title></head>
<body>
<div style="max-width: 800px; margin: 0; padding: 30px 0;">
<table width="80%" …Run Code Online (Sandbox Code Playgroud) 我有兴趣将离子auth用于我的HMVC模式运行的项目.该应用程序是用Codeigniter编写的.
我面临的问题是,一旦离子auth被放置在/ app/modules/auth文件夹中,当我尝试访问模块时,我得到以下错误:
HTTP错误500(内部服务器错误):
服务器尝试完成请求时遇到意外情况.
请帮帮我,我确信我遇到了某种配置/路径问题但是无法弄清楚在哪里.
我只是从github下载了ion_auth文件并将提取的文件放在模块文件夹中我删除了所有加载库的行,例如数据库,session,因为我已经使用了配置来自动加载它们.但是我离开了ion_auth库的加载.
在模块文件夹modules/auth中,我有一个类似的应用程序结构,具有模块特定的配置,库等文件夹.
让我知道我一定做错了什么,我将继续搜索并解决这个问题并发布如果我有运气的话.
我正在使用CodeIgniter编写图像上传表单.我之前有类似的代码可以在不同的网站上工作.目前 - 接收多部分/表单数据映像的代码无声地失败.在配置服务器/脚本时,我收到了错误,例如错误的文件路径,不同的mime-types,但现在我什么都没得到.
下面的代码返回:"ABC"并在"D"之前失败而没有错误.
如果我将'photo_filedata'更改为'photo_filedata2',我会收到更有用的错误:"ABCD您没有选择要上传的文件."
我完全没有调试这个,因为我从服务器上没有任何错误.
有谁知道可能会发生什么?
服务器:WAMP,在Windows 7上运行.有一个现有项目可以正常上传文件.
function upload_photo()
{
echo "A";
$config['upload_path'] = './images/uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['file_name'] = 'photo_' . substr(md5(time()), 0, 16);
$config['max_size'] = 2000;
$config['max_width'] = 0;
$config['max_height'] = 0;
echo "B";
$this->load->library('upload', $config);
echo "C";
$result = $this->upload->do_upload('photo_filedata');
echo "D";
if (!$result)
{
$error = $this->upload->display_errors();
$data = false;
}
else
{
$error = false;
$data = $this->upload->data();
}
$this->load->view('home-photo-upload', array('error' => $error, 'data' => $data));
}
Run Code Online (Sandbox Code Playgroud) 我想知道如何在codeigniter中向file_upload添加属性
现在我正在使用 form_open_multipart('controller');
但我想为它添加一个id属性.
任何帮助表示感谢!
我是PyroCMS的新手并且努力在论坛上获得帮助(响应缓慢,活动最少等).所以,我希望有人在这里可以提供帮助.
如何在模块之间共享资源(例如模型,控制器,视图等)?似乎每个模块都是自包含的,无法访问其他模块的资源.这将给我们带来麻烦.
我不喜欢将这些公共资源放在主要的PyroCMS安装中.这对我来说在建筑上似乎是错误的.
我正在尝试上传图片并调整它们的大小,到目前为止上传工作还有拇指指甲图像的创建.但我不能让原始图像调整大小.所有发生的事情是文件以原始大小直接上传到文件夹.我想我正在尝试将此图像调整大小然后覆盖最初上传的文件.
这是我的代码,我错过了什么:
//Initialise the upload file class
$config['upload_path'] = './image_uploads/';
$config['allowed_types'] = 'jpg|jpeg|gif|png';
$config['max_size'] = '6048';
$this->load->library('upload', $config);
$userfile = "_upload_image";
//check if a file is being uploaded
if(strlen($_FILES["_upload_image"]["name"])>0){
if ( !$this->upload->do_upload($userfile))//Check if upload is unsuccessful
{
$upload_errors = $this->upload->display_errors('', '');
$this->session->set_flashdata('errors', 'Error: '.$upload_errors);
redirect('admin/view_food/'.$food->course_id);
}
else
{
//$image_data = $this->upload->data();
////[ THUMB IMAGE ]
$config2['image_library'] = 'gd2';
$config2['source_image'] = $this->upload->upload_path.$this->upload->file_name;
$config2['new_image'] = './image_uploads/thumbs';
$config2['maintain_ratio'] = TRUE;
$config2['create_thumb'] = TRUE;
$config2['thumb_marker'] = '_thumb';
$config2['width'] = 75;
$config2['height'] = 50;
$this->load->library('image_lib',$config2); …Run Code Online (Sandbox Code Playgroud) 我目前正在写关于网络安全的论文.我专注于在Web应用程序中使用身份验证库.作为其中的一部分,我正在为CodeIgniter编写一个库,旨在通过实现对许多OAuth提供程序的支持来提供单点登录类型的身份验证.
我对你们的问题,社区如下:
到目前为止,我对此的考虑是关于速度,代码的简单性,应用程序开发人员的实现简单性以及最重要的是产品的实际安全性.
任何反馈都会受到高度重视.非常感谢.