I really don't know what causes this error.
CDbCommand failed to execute the SQL statement: CDbCommand failed to prepare the SQL statement: SQLSTATE[HY000]:
General error: 1 table 'YiiSession' already exists. The SQL statement executed was:
CREATE TABLE 'YiiSession' (
"id" CHAR(32) PRIMARY KEY,
"expire" integer,
"data" BLOB
)
Is it in the server or in yii..
but i guess it is in the yii part.
but what configurations did i miss?
i'm not really familiar with yii because im new to it.
any help please?
Thanks in advance
UPDATE: I check YiiSession in my database but it is not in there...
Delete the runtime folder.
Because runtime folder is used by the system for various tasks: session, logging etc.
It is also in the runtime folder that YiiSession table is created
In case anyone is still referencing this - the more complete answer is that Yii uses a SQLite3 database by default if you don't specify a connection string in your (CDbHttpSession) session config. This SQLite db is created in the runtime folder. (Which is why deleting the contents of the runtime folder works - you actually only need to delete the session-x.x.xx.db file.) If you want to use the same database you are using for your main connection, add:
'connectionID'=>'db',
to your session config. It's also recommended for production use you set autoCreateSessionTable to false, which will also prevent the error - you just need to make sure you deploy the SQLite db or set up the proper table in your main db. see here
By default, it will use an SQLite3 database named 'session-YiiVersion.db' under the application runtime directory. You can also specify connectionID so that it makes use of a DB application component to access database.
Related
A bit about my current setup, The website is hosted on a windows server 2012 IIS with PHP 7.1, the site runs using Laravel with Medoo to load the database, however on any form of SQL statement the code fails with the error mentioned in the title.
Currently the file permissions are on Full Control for debug purposes
The code used for the call is the following
$pdo = new \Medoo\Medoo([
'database_type' => 'sqlite',
'database_file' => $config->database_path
]);
$query = $pdo->select('computers', '*');
I have tried making a SQL dump of the SQLite database file using a program called "DB Browser for SQLite" and the making a new database file from scatch then importing the SQL dump.
When this is done the program works without problem, so my current thought is there might be a limit on PDO SQLite file limit size since the original file is about 2.8MB while the new is 1.9MB
Is there anyone who have encounter a similar problem? or have any advice on how to fix the current problem?
I have linked SQL Server into Active Directory and am trying to use PHP to create an ODBC connection to pull in the data. I can read from Active Directory fine but when I try and update it using SQL UPDATE, I get this error
Msg 7390, Level 16, State 2, Line 1
The requested operation could not be performed because OLE DB provider "ADSDSOObject" for linked server "ADSI" does not support the required transaction interface.
I know I have to use PHP's LDAP functions but I am not sure how to rewrite the LDAP string to use in PHP. My best guess would be:
I tried (example string):
OU=staff,DC=example,DC=internal
but this doesn't work. My question is: assuming there is no way of updating Active Directory from my SQL view, how do I go about updating LDAP with PHP?
I have two applications inside one Codeigniter instance (Codeigniter 3.0). I need to share database config between applications. In each application I have config:
include_once 'application/shared/config/database.php';
But I have error on application start:
No database connection settings were found in the database config
file.
I decide to check variable
include_once 'application/shared/config/database.php';
var_dump(isset($db));
And what I see?
boolean true
boolean false
I'm trying to find difference between DB initializations, but not founded yet.
include instead of include_once is solution, but I think it is not correct.
What is the best solution?
I have a problem with an SQLite3 database where I can access it either with the sqlite3 command or with the PHPStorm built-in database manager but the application I am working on doesn't find the tables in it. It correctly connects to the database it seems.
This line of PHP causes the PDOException:
$query = "SELECT * FROM users";
$results = self::$app->db->query($query);
And the exception is simply SQLSTATE[HY000]: General error: 1 no such table: users. I am using the Slim framework, by the way.
I don't really know what to do as I am new to Slim as well as SQLite.
Thank you for your help :-)
The database that you have opened does not contain this table.
SQLite will happily open any file name; if it does not exist, it will create a new, empty database.
Check your database file name.
Thanks to the accepted answer that pointed me in the right direction.
I am using Symfony 4.1 and realized that the base directory for Symfony is the public directory (should be app in 2.8) so to open my database I had to do :
# file: PROJECT_ROOT/.env
DATABASE_URL="sqlite:///../my_super.db"
But then, every call to doctrine in a command (like doctrine:schema:update) must be called in a direct subfolder of the project, like so:
PROJECT_ROOT/bin$ ./console doctrine:schema:update --dump-sql
I have Microsoft Access Database (mdb file) with a table in it (we'll call that table A) that is linked to another Microsoft Access Database (we'll call that table B). I need to be able to update table A using php (which will in turn update table B, since A is linked to B). Please note that the table I'm linking to has a primary key named "Intersection" and it is set to Indexed: Yes (No duplicates).
If I use a simple odbc_connect and odbc_exec to run the following query:
$con= odbc_connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$mdbFilename", $user, $password)
$res = odbc_exec($con, "UPDATE tableA SET myfield=NULL WHERE myfield=2439;");
However, when I try this on a database with a linked table, I get the following error:
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC
Microsoft Access Driver] Operation must use an updateable query., SQL
state S1000 in SQLExecDirect in G:\web\libs\test.php on line 413
For some reason it seems that my database is not updateable even though it should be. It has a primary key defined and is a simple table (except for the fact that it's linked). Originally I was getting the following error:
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC
Microsoft Access Driver] 'H:\test\Database\test.mdb' is not a valid
path. Make sure that the path name is spelled correctly and that you
are connected to the server on which the file resides., SQL state
S1009 in SQLExecDirect in G:\web\libs\test.php on line 413
But then I changed my linked table so instead of using drive letters to navigate to the linked table, I used the absolute \server\ path, which seemed to fix that problem, however not it is not able to be updated.
In case it helps, to create the Linked table, all I did was (Using MS Access 2010) I hit the "External Data" tab, then the "Access" (button), then I made sure to hit "Link to the source by creating a linked table" (option) and I selected the other database which contains the original table.
Is there some way to run an update on a linked access table using php?
Again, if you have a MS Access linked table that is linked to another table, and these tables have a primary key that is properly indexed. You CANNOT update the table using the following above PHP code (even though it works completely fine on an table which is not linked).
Please note, I have tested this with a fresh accdb database file as well, and if it is a linked table, it seems it will become read-only if you try to update the table using odbc_exec, however it does return data just fine, I just can't insert or update records.
Thank you.
[UPDATE]
Our server is running Windows Server 2003 with apache, and php. So I set up a Windows 7 machine with apache, and php, and it IS able to update a linked database without a problem, so I suspect my problem (since it's the only difference between the machines that could affect this), is that the Win2003 server is running odbc v3.5 whereas my win7 Machine is running odbc v6.1. I'm still looking into this further and will update this post if I find a solution to getting it working on our Windows Server 2003 machine.