Welcome Guest, Not a member yet? Register   Sign In
can temporary tables be used in PHP?

(This post was last modified: 09-29-2022, 12:18 AM by JustJohnQ.)


Some more testing:

PHP Code:
$sql "CREATE TEMPORARY TABLE BC_PR_list_temp(taxyear VARCHAR(10))";

$sql "INSERT INTO BC_PR_list_temp (taxyear) VALUES (1984)";

$sql "SELECT * FROM BC_PR_list_temp";
$result $this->db->query ($sql);
$data $result->result ();

This works fine within a function, so the temp table is created. As mentioned earlier, it will be deleted once the db session is closed.

PHP Code:

table_exists() doesn't work for temporary tables, the result is always false. As a matter of fact, it is not easy to check if a temporary table exists using SQL.

Conclusion: it is not a CI problem, but a MySQL limitation when working with temporary tables. I suggest you find a way to work with normal tables.

Messages In This Thread
RE: can temporary tables be used in PHP? - by JustJohnQ - 09-28-2022, 01:02 PM

Theme © iAndrew 2016 - Forum software by © MyBB