I am upgrading ci 2 to ci 3.11
I have done all the changes in upgrading,
Still i get this error
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE id = 'gr6rnf66t7d20oqlkocr5ate3nlg3equ'' at line 2
SELECT 1 WHERE id = 'gr6rnf66t7d20oqlkocr5ate3nlg3equ'
Filename: D:/xampp/htdocs/XXXX/system/database/DB_driver.php
Line Number: 691
I want to know from while file this database querying.
Just now i found that if i change
$config['sess_cookie_name'] = 'ci_session';
this value id in the query is changing
For now i changed to sess_driver to files in config to work
I didn't give $config['sess_save_path'] = 'ci_sessions'; (Its the table name of session)
Related
I'm using SQL Server within my Laravel application. I need to group/sum a table for the month/year. My query looks like this:
$positions = BelegPos::select(
DB::raw("YEAR(Datum) as year"),
DB::raw("MONTH(Datum) as month"),
DB::raw("SUM(Menge) as stunden")
)->groupBy("year", "month")
->get();
I'll get the following error message:
SQLSTATE[42S22]: [Microsoft][ODBC Driver 17 for SQL Server][SQL
Server]Invalid column name 'year'.
I don't know what's wrong, as the query the way I build it works fine with MySQL servers.
Thanks for any hint in the right direction.
UPDATE
I researched a bit more and read about somthing that points out, that the Select Statement isn't available in the GROUP BY section and that you have to add the same query there. so my query looks now like this:
$positions = selectlineBelegPos::select(
DB::raw("YEAR(Datum) as the_year"),
DB::raw("MONTH(Datum) as the_month"),
DB::raw("SUM(Menge) as stunden")
)
->groupBy(DB::raw("YEAR(Datum) as the_year"),DB::raw("MONTH(Datum) as the_month"))
->get();
Still not the solution but the error message has changed to this:
SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL
Server]Incorrect syntax near the keyword (SQL: select
YEAR(Datum) as the_year, MONTH(Datum) as the_month, SUM(Menge) as
stunden from [BELEGP]
So I think there is just one small thing wrong but can't figure out what.
Any ideas?
Solution
Just found the the solution:
$positions = selectlineBelegPos::select(
DB::raw("YEAR(Datum) AS year"),
DB::raw("MONTH(Datum) AS month"),
DB::raw("SUM(Menge) AS stunden")
)
->groupBy(DB::raw("YEAR([Datum])"),DB::raw("MONTH([Datum])"))
->get();
Indeed isn't the dynamically value names (year and month) unavailable in the GROUPBY clause, instead you have to call the DB::raw again but now without generating the key words again.
thank you all for the support!
I've been instaling one of our products on a new test server and it's not working due to an error 264 - the column name 'kod_novy' is specified more than once in the SET clause.
I know where the problem is and reported it to the development for a fix. But we have the same application deployed and it works just fine.
In the code you can see the 'kod_novy' is used twice in the insert. My question is - does anyone know, how did our customer manage to ignore this error and successfully complete the T-SQL? Is that a server setting?
Thanks,
Z
insert into [server].db.dbo.prenos_c_banky (
id_prenos,
kod,
kod_novy,
ext_kod,
iud_job,
kod_banky,
kod_novy,
nazev,
znacka)
select
cast('2B06FB0A-2664-4714-91F6-A6D39BDE5B5F' as UNIQUEIDENTIFIER),
kod,
kod_novy,
ext_kod,
iud_job,
kod_banky,
kod_novy,
nazev,
znacka
from #c_banky
I use DB::setDatabaseName(<database name>) to reset the databasename, then I use DB::table(<table name>)->get() to retrieve data. However laravel does not change to new database.
This is my error message:
Illuminate/Database/QueryException with message 'SQLSTATE[42P01]:
Undefined table: 7 ERROR: relation "t" does not exist LINE 1: select
* from "t" ^ (SQL: select * from "t")'
The table t is in another database. I think when I use DB::setDatabaseName(<database name>) it would work.
Thank you for your help!
I don't know your database of detail information, but this help you to check database have changed.
// current database is 'db_1'
echo DB::getDatabaseName(); // return db_1
// Set database to 'db_2'
DB::setDatabaseName('db_2');
// If success, should return 'db_2' now.
echo DB::getDatabaseName();
// Check database tables.
DB::select('show tables');
I was facing a similar issue.
But changing the database solely might not always work.
You could use config->set() like so
config()->set('database.connections.mysql', $database_name);
But in my case I had to reconnect the database to change it dynamically.
So maybe this one works for the OP.
\DB::disconnect();
config()->set('database.pgsql.database', $database_name); // psgl = Postgress
\DB::reconnect();
You'll find more info here Laravel 6 config()->get('database.connections.mysql') not matching DB:connection()
Hope it helps
I am ASP.NET/C#.NET developer who is new to Drupal 7. We have installed Drupal 7 on a WISP stack (Windows Server 2012 R2, IIS 8.5, SQL Server Express 2012, PHP 5.4). The problem we are encountering is as follows: I installed the Tag Clouds (https://www.drupal.org/project/tagclouds) module and then try to configure it. When I saved the configuration the Drupal website suffered
a HTTP Error 500.19 - Internal Server Error
As a result I cannot browse to the website now. I cannot access the Admin menu to remove the Tag Clouds module.
I have tried to resolve the issue by following the instructions in this MS Support article:
https://support.microsoft.com/en-us/kb/942055
I checked Windows Event Viewer Application Log when the HTTP Error 500.19 occurred and saw the below Warning:
PDOException: SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL
Server][SQL Server]Incorrect syntax near the keyword 'AS'.:
SELECT TOP(12) td.[tid] AS [tid], td.[vid] AS [vid], td.[name] AS [name], td.[description] AS [description], COUNT(*) AS count, max(n.nid) AS nid, COUNT(*) AS _field_0, td.tid AS _field_1, td.vid AS _field_2, td.name AS _field_3, td.description HAVING COUNT(*) > 0 AS _field_4
FROM
{taxonomy_term_data} td
INNER JOIN {taxonomy_index} tn ON td.tid = tn.tid
INNER JOIN {node} n ON tn.nid = n.nid
WHERE ( ([td].[vid] IN (:db_condition_placeholder_0)) AND ([n].[status] = :db_condition_placeholder_1) )
GROUP BY td.tid, td.vid, td.name, td.description HAVING COUNT(*) > 0
ORDER BY COUNT(*) DESC; Array
(
[:db_condition_placeholder_0] => 1
[:db_condition_placeholder_1] => 1
)
in tagclouds_get_tags() (line 275 of F:\Inetpub\wwwroot\acquia-drupal7\sites\all\modules\tagclouds\tagclouds.module).
Any help with this issue is much appreciated.
The first step is to disable the module so that your site works again. Use the SQL found here at https://www.drupal.org/node/157632.
The module appears to use the proper db_select() function, so I'm not entirely sure why SQL Server doesn't like the syntax.
Which version of Drupal are you using? It's possible that a more recent release has fixed the MSSQL driver.
I have a SQL Server CE database file and I have ADO.NET Entity Framework object named History. I perform the following to get the latest ID:
var historyid = (from id in db.Histories // Get the current highest history Id
select (Int32?)(id.Id)).Max();
HistoryID = Convert.ToInt32(historyid);
if (HistoryID == 0) // No current record exists
{
HistoryID = 1; // Set the starter history Id
}
(Not the best way, but it is just to test).
This works well and returns the correct value (If I manually enter an ID of 1, it returns 1, same with 2 etc..)
The issue is with the following code:
History history = new History();
history.Id = 1;
history.SoftwareInstalled = "test";
db.AddToHistories(history);
db.SaveChanges();
The above works and runs through fine, but the changes are not saved to the database! Why is this?
Here is my db variable: dbDeSluggerEntities db = new dbDeSluggerEntities();
Thanks.
Edit: Here is an update: I noticed when I run the program and debug it, it shows that a history has been created and inserted and also gives an error of the primary key already existing, this happens each time I run the application (over and over). However, when I go to server explorer and right click the db and select 'Show Table Data' it shows no data.. When the program is run again, there is no primary key error or history's showing in the debug!
I was having exactly the same problem. By default the database is copied into your bin folder when you run the app and that is used.
My solution was to go into the properties of the db and set it to never copy and to put a full file path to the database in the connection string in the apps config file.