Sphider MySQL Tables - mysql

I'm trying to install Sphider to search my site and when I try to create the MySQL tables I am getting this error:
create table query_log (
query varchar(255),
time timestamp(14),
elapsed float(2),
results int,
key query_key(query)
) ENGINE = MYISAM;
MySQL said: Documentation
\#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(14),
elapsed float(2),
results int,
key query_key(query)
) ENGINE = MYI' at line 3
How do I get round this?

According to the Sphider forums, it looks like this is an issue with the TimeStamp field type, or at least the way it's used in this CREATE TABLE query. (http://www.sphider.eu/forum/read.php?2,8933). On that forum page it is suggested that you:
1) editing the admin/install.php file,
2) Changing line 139,
FROM:
time timestamp(14),
TO
time timestamp,

There is no such thing as a timestamp(14).
The code should just be:
time timestamp;
Remove the (14)
Where the heck did you get that from, that they wouldn't understand basic mysql syntax?

Related

MySQL vs MariaDB - ddl - setting default for time field

I've got table products, and want to add column with type time.
I've got statement as follows:
ALTER TABLE products ADD openTime1 TIME DEFAULT TIME(now());
it works on MariaDB, but it doesnt work on Mysql.
On mysql it produces Error -
[42000][1064] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(now())' at line 1
Can someone tell me why? whats wrong here? I thought that this should be the same.
In MySQL the expression used in DEFAULT field attribute must be wrapped into the parenthesis:
ALTER TABLE products ADD openTime1 TIME DEFAULT (TIME(now()));
db<>fiddle here

Column with date data type and Date functions

I´m practicing Data Types (Dates) and MySQL date functions. So, just for practice, I´m trying to create a table and use both (the previous ones) for “x” column. I also want to do it with other date functions in case if it´s possible to do it.
So,
CREATE TABLE testing (
idtesting INT NOT NULL AUTO_INCREMENT KEY,
testingdate date NOT NULL DEFAULT CURDATE()
) ENGINE MyISAM;
If I´m not wrong date data type expects something like: YYYY-MM-DD and curdate() returns YYYY-MM-DD
But, I´m receiving this ERROR
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CURDATE()
) ENGINE MyISAM' at line 3
Even when I searched ERROR 1064 (42000), I can´t find a solution.
Anyone can help me?
And yes, I want to mix data types and dates functions just to learn.
Thanks a lot!
MySQL is very particular about setting default datetime/timestamp columns. The current date is not permitted -- either a timestamp or datetime (depending on the version of MySQL).
You can read about the defaults in the documentation.
(Note: initializing datetime columns is only allowed since 5.6.5. In earlier versions, only timestamp columns could be initialized.)

Create Table DECIMAL Error

I am working with a Raspberry PI running Raspbian. I've gotten to the point where I'm setting up a MySql database and I am trying to create a DECIMAL table.
I'm following this guide.
This is the code i'm using
Use Monitoring;
create table TempHumid (ComputerTime INTEGER UNSIGNED);
#This one created the table, but it was a different type.
create table Temperature (DECIMAL(5,1);
create table Humidity (DECIMAL(5,1);
This is the error that it gives me.
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near 'DECIMAL (5,1))' at line 1
I tried looking around on Google and on here, but those solutions didn't seem to work. I'm fairly new to the PI, so it may just be user error.
You should specify your columns. See below:
CREATE TABLE Temperature (
Temperature DECIMAL(5,1)
);
CREATE TABLE Humidity (
Humidity DECIMAL(5,1)
);

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(14),

Creating a search engine for my website with the help of Sphider
but when creating the MySQL database tables the following error message showed
Error
SQL query:
create table query_log (
query varchar(255),
time timestamp(14),
elapsed float(2),
results int)
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(14),
elapsed float(2),
results int)' at line 3
The problem lies with the number following your timestamp declaration. MySQL documentation says of the timestamp type:
the display width is fixed at 19 characters, and the format is 'YYYY-MM-DD HH:MM:SS'.
So, your code can be fixed by making the following modification:
create table query_log (
query varchar(255),
time timestamp,
elapsed float(2),
results int
)
As far as the number "14" goes, it's unclear where you were going with that. Does the project you are working on require that a timestamp of a specific length? If so, it might be best to use another data type, or to convert the timestamp to the desired format after it is pulled from the database.
I am new on StackExchange, so I hope that I've adequately answered the question. Please let me know if I can help with anything else!

Symfony doctrine::build task cannot create table named order

I have a database with a table named order.
When i run php symfony doctrine:build --all, i got the folowing error:
SQLSTATE[42000]: Syntax error or
access violation: 1064 You have an
error in your SQL syntax; check the
manual that corresponds to your MySQL
server version for the right syntax to
use near 'order (id BIGINT
AUTO_INCREMENT, status VARCHAR(255),
colissimonumber VARCHAR(25' at line 1.
Failing Query: "CREATE TABLE order (id
BIGINT AUTO_INCREMENT, status
VARCHAR(255), colissimonumber
VARCHAR(255) NOT NULL, created_at
DATETIME NOT NULL, updated_at DATETIME
NOT NULL, PRIMARY KEY(id)) ENGINE =
MyISAM".
The problem is clearly that order has no backquotes arount it (if i run manually the query in phpmyadmin with backquotes, it works)
How do i tell doctrine to add backquotes around table and field names? Any workaround exept renaming my table ?
I run symfony 1.4.9 with doctrine 1.2
You can turn on Doctrine_Core::ATTR_QUOTE_IDENTIFIER in your doctrine configuration mthod on projectConfiguration which will quote tables and col names but its not recommended:
Just because you CAN use delimited
identifiers, it doesn't mean you
SHOULD use them. In general, they end
up causing way more problems than they
solve. Anyway, it may be necessary
when you have a reserved word as a
field name (in this case, we suggest
you to change it, if you can).
http://www.doctrine-project.org/projects/orm/1.2/docs/manual/configuration/en#identifier-quoting
You probably want your model to be named Order, but this doesn't mean that the corresponding RDBMS table must be named the same.
Order:
tableName: project_order
columns: ...
Got similar error when upgrading from MySQL 5.7 to MySQL 8.0. RANK() is a function added in MySQL 8.0 whereas one of the table in our database has rank as column name.
My Setup:
- Symfony 1.5
- Doctrine 1.2
- PHP 7.4.24
- MySQL 8.0.27
- Ubuntu 20.04.1
Here are three possible solutions.
Solution 1: Add quote_identifier: true in config/databases.yml file. Also, clear cache after change in configuration with php symfony cc or php symfony cache:clear.
all:
doctrine:
param:
attributes:
quote_identifier: true
Solution 2: Turn on Doctrine_Core::ATTR_QUOTE_IDENTIFIER in config/ProjectConfiguration.class.php file on configureDoctrine() method.
$conn = Doctrine_Manager::getInstance()->getCurrentConnection();
$conn->setAttribute(Doctrine_Core::ATTR_QUOTE_IDENTIFIER, true);
Solution 3: Turn on Doctrine_Core::ATTR_QUOTE_IDENTIFIER on specific table(s) which are potentially breaking the system.
$table = Doctrine_Core::getTable('table_name');
$table->setAttribute(Doctrine_Core::ATTR_QUOTE_IDENTIFIER, true);
Note: From Doctrine 1 docs
Just because you CAN use delimited identifiers, it doesn't mean you
SHOULD use them. In general, they end up causing way more problems
than they solve. Anyway, it may be necessary when you have a reserved
word as a field name (in this case, we suggest you to change it, if
you can).