我正在尝试学习Codeigniter并了解到目前为止的基础知识,但是当我尝试测试时,似乎缓存正在阻碍.通常,当我在localhost上测试时,我做了一个更改并立即在浏览器中看到它,但是使用Codeigniter,似乎我需要等待~1分钟才能在浏览器中看到更改.有没有办法普遍禁用Codeigniter缓存,以便在发生变化时立即发生?
伙计们.我正在使用codeigniter.我使用.htaccess从我的url中删除'index.php',并将"Allow from all"添加到我的default.conf中.'index.php'已成功删除,网站正在运行.但是自上次更新apache以来,.htacess停止了工作,并且在URL中需要'index.php'.这是我新更新的000-default.conf.
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless. …Run Code Online (Sandbox Code Playgroud) 我遵循数据库架构 -

现在部门,年份和部门表已经填满了信息.
我现在需要插入学生数据.学生数据将从xls文件导入(导入和解析部分已完成).正如您在架构中看到的那样,表中的列student_data引用year_id,department_di和division_id.因此,在插入时我需要他们的ID字段,因为xls具有各自的名称值.
所以我要根据每个学生的列值来获取相应的ID.因此,这引入了3个查询,用于在学生表中插入一条记录.像这样 -
forloop(...):
$studentData = new Entities\StudentData();
$year = $this->em->getRepository("Entities\Year")->findBy(array('year_name' => $this->year[$i]));
$department = $this->em->getRepository("Entities\Department")->findBy(array('department_name' => $this->branch[$i]));
$division = $this->em->getRepository("Entities\Division")->findBy(array('division_name'=>$this->division[$i]));
$studentData->setYear($year[0]);
$studentData->setDepartment($department[0]);
$studentData->setDivision($division[0]);
//other data
.
.
.
.
.
$this->em->persist($studentData);
endforloop();
$this->em->flush();
$this->em->clear();
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我将为每个部门,年份和部门获得ID循环.假设我正在导入100个学生列表,因此它最终会运行300个查询来获取这3个ID字段.
我可以在插入数据时直接从他们的名字中获取年份,部门和部门的ID吗?我是学说的新手,我不知道如何去做.
更新 如果问题不清楚,请告诉我.我可以用更多细节更新它或重组它.
我正在制作一个网页,这是一个单页网站,通过CodeIgniter中的Ajax与服务器进行交互.一般编码具有以下类型:
controller (user.php):
public function get_user_content() {
$id = $this->input->post('id');
$hits = $this->user_model->user_data($id);
$s = '';
foreach ($hits as $hit) {
$s .= $hit->name;
$s .= $hit->age;
}
echo $s;
}
Run Code Online (Sandbox Code Playgroud)
model(user_model.php):
function user_data($id) {
//do sql operation
return $query->result();
}
Run Code Online (Sandbox Code Playgroud)
视图:
...
...
<a href="#" id="23" class="user-data">Click here for user details</a>
...
...
Run Code Online (Sandbox Code Playgroud)
JavaScript的:
('.user-data').click(get_user_data);
....
....
function get_user_data(response) {
return $.ajax({
type: "POST",
url: "<?php echo base_url();?>index.php/user/get_user_content",
data: { id: this.id },
success: function(response) {
$("#somediv").append(response); …Run Code Online (Sandbox Code Playgroud) 我正在使用codeigniter会话来存储用户登录.当用户在多个选项卡中打开时,在一个选项卡中注销时,我希望在用户访问其他选项卡时自动刷新页面.这可能吗?
使用带有我的codeigniter应用程序的SMTP时,我无法收到要发送的电子邮件.
在SO上有很多类似的问题,但没有一个可以解决我的问题,所以这就是为什么我要再问一次.
这是我得到的错误:
hello:
The following SMTP error was encountered:
Failed to send AUTH LOGIN command. Error:
from:
The following SMTP error was encountered:
to:
The following SMTP error was encountered:
data:
The following SMTP error was encountered:
The following SMTP error was encountered:
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
User-Agent: CodeIgniter
Date: Tue, 22 Apr 2014 22:54:12 -0400
From:
Return-Path:
To: myemail@gmail.com
Subject: =?utf-8?Q?Request_from_C&J_Builders_Contact_form?=
Reply-To: "donotreply@C&JBuilders.us" …Run Code Online (Sandbox Code Playgroud) 浏览器:
无法找到指定的类:Session.php
这是我的控制器:
<?php
class Chat extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('Chat_model');
}
public function index() {
$this->view_data['chat_id'] = 1;
$this->view_data['student_id'] = $this->session->userdata('student_id');
$this->view_data['page_content'] = 'chat';
$this->load->view('chat');
}
public function ajax_addChatMessage() {
$chat_id = $this->input->post('chat_id');
$student_id = $this->input->post('student_id');
$bericht = $this->input->post('chat_id', TRUE);
$this->Chat_model->addChatMessage($chat_id, $student_id, $bericht);
}
}
Run Code Online (Sandbox Code Playgroud)
当我把我的模型放在评论中时parent::__construct(); // $this->load->model('Chat_model');,错误消失了.
这是我的Chat_model:
<?php
class Chat_model extends CI_Controller {
public function Chat_model() {
parent::__construct();
}
public function addChatMessage($chat_id, $student_id, $bericht) {
$query = "INSERT INTO tbl_chatberichten (chat_id, …Run Code Online (Sandbox Code Playgroud) 我使用codeigniter my_model类来更新我的表数据.
Actulay我需要的查询是
`UPDATE `pay_project` SET `awarded` = '129' WHERE `pay_id` = 1 and `status` ='y'
Run Code Online (Sandbox Code Playgroud)
为此,我尝试了codeignter my_model函数更新
$this->pay_project_model->update_by(array('pay_id'=>1,'status'=>'y'),$updateJob);
Run Code Online (Sandbox Code Playgroud)
但是代码不起作用,如果我正在尝试update()而不是update_by(),那么它就像这样显示
`UPDATE `pay_project` SET `awarded` = '129' WHERE 'id'=array()
Run Code Online (Sandbox Code Playgroud)
请帮帮我解决这个问题?我也尝试使用update_many(),同样不起作用..
使用的模型是 https://github.com/jamierumbelow/codeigniter-base-model
我正在尝试Soundcloud api用于我的应用程序,用户可以在其中创建自己的轨道播放列表.作为测试用例,我正在测试的示例几乎完全取自Soundcloud dev docs.下面是我的代码
<script src="http://connect.soundcloud.com/sdk.js"></script>
<script>
// initialize client with app credentials
SC.initialize({
client_id: 'MY_CLIENT_ID',
redirect_uri: 'http://localhost.local/~****/sc/callback.html'
});
// initiate auth popup and create new playlist
SC.connect(function() {
SC.get('/me', function(me) {
console.log(me.username);
});
var tracks = [12573606].map(function(id) { return { id: id }; });
SC.post('/playlists', {
playlist: { title: 'My Playlist', tracks: tracks }
});
});
Run Code Online (Sandbox Code Playgroud)
我已经在谷歌搜索了很多东西,但没有任何帮助我,实际上我需要临时播放列表所以当用户注销或关闭浏览器播放列表也删除.任何帮助都会很明显.. thanx
codeigniter ×10
php ×8
javascript ×3
mysql ×2
.htaccess ×1
ajax ×1
apache2 ×1
caching ×1
doctrine-orm ×1
email ×1
jquery ×1
model ×1
session ×1
smtp ×1
soundcloud ×1
ubuntu ×1
zoho ×1