Closed mbunal closed 2 years ago
Not sure, need more info, could be:
$db->query("CREATE TEMP TABLE temp.history( . . . )");
You could remove "TEMP". see https://database.guide/create-temporary-table-sqlite/ Or do:
$db->query("CREATE TABLE IF NOT EXISTS temp.history( . . . )");
How is the db connection setup?
exact query is:
$db->query("DROP TABLE IF EXISTS temp.history");
$db->query("CREATE TEMP TABLE temp.history(s, id, oid, oli, p, q, qq, c, ca, t, ib, im, ibm)");
foreach ($history as $h)
{
$db->insert('temp.history', $h);
}
connection is:
use ezsql\Database; // Load ezSQL Database Class
$db = Database::initialize('sqlite3', ['./database/', 'b.sqlite3']);
$db->connect();
What's $history
contents?
You should check see if the actual "$db->query(...)" returns false
, which indicates not successful/error.
Or echo $db->getLastError();
after query call.
The warning line 441 referenced is actually for some other error logged.
Also your create table is not valid as you have it. No column types, primary keys, etc...
$history is:
["s"]=> string(7) "ALLINONE"
["id"]=> int(37544933)
["iod"]=> int(620365953)
["oli"]=> int(-1)
["p"]=> string(10) "214.19500000"
["q"]=> string(11) "942.45473600"
["qq"]=> string(12) "5352.56700000"
["c"]=> string(10) "12.67415903"
["ca"]=> string(3) "WHATNEXT"
["t"]=> int(1747210393384)
["ib"]=> bool(true)
["im"]=> bool(true)
["ibm"]=> bool(true)
You need to supply full sample,, so far what you have is not correct.
Why you doing a for loop on $history
array?
That $db->insert(...)
should fail the way you have it, each step thru it's not filling all columns.
Look over our Tests script. https://github.com/ezSQL/ezsql/blob/4bc6a254b7ac9d4856da343682c9af14cbec8909/tests/sqlite/sqlite3Test.php#L152 https://github.com/ezSQL/ezsql/blob/4bc6a254b7ac9d4856da343682c9af14cbec8909/tests/sqlite/sqlite3Test.php#L98
I am assuming your issue is resolved now, reopen if not.
i have this error
Warning: table history already exists in /vendor/ezsql/ezsql/lib/ezsqlModel.php on line 441
. i use sqlite3 db. my code is:error triggered by
$db->insert('temp.history', $h);
line. where am i wrong?i know this is just warning but why this happen? i didint create table just insert???