473,324 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Temporary tables with AJAX

Hello!

I have been busting my head with a problem, that goes like this:
1. with a first ajax call to the server(apache 2.0 + php), I create a
temporary table like this:
create temporary table peter select * from some_table limit 0,0; That
creates an empty temporary table with the same structure as some_table.
I use mysql 4.023. I use php call mysql_connect to connect to the
mysql database.
2. I create a second ajax call to the server using the same
mysql_connect call with the third parameter new_link set to false and
make this query:
select count(*) as 'count' from peter; This time I receive an error
that this table does not exist.

Any ideas on where a problem could lie?

Thanks in advance.

Mar 21 '06 #1
1 3436
<pe*********@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
2. I create a second ajax call to the server using the same
mysql_connect call with the third parameter new_link set to false and
make this query:
select count(*) as 'count' from peter; This time I receive an error
that this table does not exist.


Evidently the connection is being closed and reopened somehow. Temp tables
only exist in the current database connection session.

Read the explanation of persistent connections here:
http://www.php.net/manual/en/feature...onnections.php

If you use PHP in CGI mode, you can never get persistent connections because
the PHP script is run in a new process for every request. Resources like
database connections can't be persisted from one process to another.

If you use PHP in Apache-module mode, you aren't guaranteed that the same
Apache handler process is used from one request to another. In other words,
there is no HTTP session affinity for Apache handlers. So you may get use
new_link to avoid having to reopen a connection if that handler already had
a connection, but you won't necessarily get the _same_ connection as you
used in the previous request. You don't have any way of making successive
Ajax requests (or any HTTP requests) go to the same handler. The temp table
you created is associated with one particular connection, and that
connection is associated with only one of the Apache request handler
processes.

Note also that your temp table 'peter' _will_ persist as long as its
connection is alive, and it'll likely be meaningless to most of the clients
using that connection. The temp tables may accumulate and needlessly occupy
memory or storage. In any case, they'll rapidly contain obsolete data, and
the creater of the temp table won't have access to that connection to drop
the temp table.

To do what you want, you'd need "session affinity" to make sure successive
requests from a given HTTP client go to the same Apache handler process.
Google for "apache session affinity php". FastCGI_SA may be a solution for
you.
http://www.tfarmbruster.com/fcgi_sa.htm

You might find it's easier to rethink the way you're fetching data with
Ajax, and eliminate the need for temp tables to live from one request to the
next. And be sure to drop your temp tables when you're done with them, or
else they'll accumulate.

Regards,
Bill K.
Mar 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Soefara | last post by:
Dear Sirs, I have been developing an application on Windows with MySQL 3.23, making use of temporary tables. Now when I try to port the application to a Unix box running also MySQL 3.23, I...
2
by: Ryan | last post by:
Just a quicky about temporarary tables. If using QA, when you create a temporary table, it gets dropped if you close the query. Otherwise you need to state 'DROP TABLE myTable' so that you can...
11
by: randi_clausen | last post by:
Using SQL against a DB2 table the 'with' key word is used to dynamically create a temporary table with an SQL statement that is retained for the duration of that SQL statement. What is the...
1
by: Sampath Reddy | last post by:
Hi Everybody, We are using UDB v8.1 I will explain about my Stored procedures which we are executing in UDB AIX box. We have 3 millions(apporox) of data in 22 tables. By applying the business...
2
by: Keith Watson | last post by:
Hi, we are currently implementing an application running on DB2 V7 on Z/OS using largely COBOL stored procedures, managed using WLM. Some of these stored procedures declared global temporary...
2
by: Chuck Crews | last post by:
I am interested in declaring a global temporary table within an application. The application processes 1 set of 600 or less rows each iteration. Multiple programs can and do call this one...
3
by: Mike Ridley | last post by:
I have 2 databases called (for example) "progs.mdb" and "files.mdb". Both these databases reside on computer "myserver". The progs database has links to the tables in the files database....
1
by: Stefan van Roosmalen | last post by:
Hi there, Is there a way to list the TEMPORATY tables? I have tried SHOW TABLES, but this command only list the regular tables. Thank you very much for your answer. Regards, Stefan.
5
by: Rahul B | last post by:
Hi, I have very little knowledge about creating Procedures/functions in DB2. When i tried to create the test function like CREATE FUNCTION GET_TEST (P_TEST_ID INTEGER, P_SEL_OR_SORT...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.