English 中文(简体)
密码用户在请求之间分享我的舱面。
原标题:Does codeigniter share mysql sessions between http request

在使用密码用户数据库类别时,有两种不同方式要求使用相同的我sql链接/占有权(例如,thi->db)? 我听到,有些框架确实说,但我的项目取决于制定准则者这样做的希望。 因此,我正在编制临时表格,每一份请求都需要有适当的临时表格,而不是分享。 谁能澄清?

edit

我也正在用桌锁。

最佳回答

YES。 如果你的框架组合使用持续的联系,那么所有临时表格将从一个电话到另一个电话。 如果你不使用持续的联系,那么在文字结尾处会自动断断断断断断线,下一个文字将开新。 如果你在你的呼吁中依靠轮椅,而且需要加以区别,则应当谨慎。 Per MYSQL矿址:

A TEMPORARY table is visible only to the current connection, and is dropped automatically when the > connection is closed. This means that two different connections can use the same temporary table name without conflicting with each other or with an existing non-TEMPORARY table of the same name.

rel=“nofollow”http://dev.mysql.com/doc/refman/5.1/en/create-table.html

你提到了框架,因此,这是《国际公认准则》中你的一个实例。 建立控制员。 让我们呼吁的是CTRL,然后是一套方法步骤1、步骤2、步骤3、步骤4。 你实际上只需要1和2个,但我只做了一点:

function step1()
{
    $this->your_model->db->query("CREATE TEMPORARY TABLE test (col1 int null);");
    $this->your_model->db->query("INSERT INTO test values (1);");
}

function step2()
{
    $res = $this->your_model->db->query("SELECT * from test;");
    print_r($res->result_array());

}
function step3()
{
    $this->your_model->db->query("INSERT INTO test values (2);");
    $this->your_model->db->query("INSERT INTO test values (3);");

}
function step4()
{
    $res = $this->your_model->db->query("SELECT * from test;");
    print_r($res->result_array());

}

如果你以与西非经货联盟挂钩的方式来实施上述规定,则在当时这样做:

http://yoursite/CTRL/step1
http://yoursite/CTRL/step2
http://yoursite/CTRL/step3
http://yoursite/CTRL/step4

你们的数据将插入,然后从电话中显示,这意味着你的TEMP表仍然在那里。

现在,改换与FLSE的连接,更换你的服务器并重新管理上述服务,你可以:

Table  yourdb.test  doesn t exist

SELECT * from test;

Filename: C:yourpathsystemdatabaseDB_driver.php
问题回答

HTTP is a stateless protocol, and as such - each PHP script is executed and terminated on separate requests, so there s no way to maintain any persistent connection between requests, unless it s handled by an external process. Even if you use HTTP/1.1 with Keep-alive on, even though multiple HTTP requests are handled by a single Apache (for example) process/thread and connection - separate requests still represent different script executions. This doesn t have to do anything with CodeIgniter. However, if you ve set pconnect on for your database connection, PHP will try to reuse the same database connection when possible. This still doesn t mean that it s the same session.





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签