I've an existing CodeIgniter Application with lot of pages where all the page titles( h1 tag ) are hard coded in the views. Now I'm looking to populate the titles dynamically from the below table structure with as much less effort as possible.
CREATE TABLE `page_title` (
`id` int(11) NOT NULL,
`page_no` tinytext NOT NULL,
`page_title` varchar(255) NOT NULL,
`date` tinytext NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
ALTER TABLE `page_title`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
Need suggestion on how to display the title with a good approach. I was thinking to create a common model and call the model in the view with page_id pass to get the page_no and page_title for that id.
I'm using Spring boot, and I have to initiate two tables for testing. I'm using the schema.sql inside the resource folder. But when I'm trying to create two tables in the same script and run the app, it can't load the application context.
Here is my schema.sql which I have placed at resource folder:
CREATE TABLE JobStatus_FO
(
id int(11) NOT NULL AUTO_INCREMENT,
businessDate timestamp NOT NULL,
label varchar(50),
);
CREATE TABLE JobStatusDetails_FO
{
id int(11) NOT NULL,
name varchar(50),
};
Please find the correct scripts as
CREATE TABLE JobStatus_FO
(
id INT(11) NOT NULL AUTO_INCREMENT,
businessDate TIMESTAMP NOT NULL,
label VARCHAR(50),
KEY id(id)
);
CREATE TABLE JobStatusDetails_FO
(
id INT(11) NOT NULL,
NAME VARCHAR(50)
);
Your syntax is not correct of create table .
1) In your scripts you have used extra comma "," before closing parentheses
2) Auto increment column should be used as a key in table
3) Curly braces "{" is not used within create table.
Hope this will work in to your project.
This may be a feature instead of a bug, so I thought to include it on SO instead of MariaDB's Jira.
Yesterday I updated my MariaDB install on Homebrew from 10.1.23 to 10.2.6. All my selects are still working correctly, but now in my legacy app, I get a bunch of errors on inserts where the code is "assuming" MariaDB will set a default value. For example...
INSERT INTO table SET
email = 'some#email.com', -- varchar
phone_number = '', -- bigint
ts = '2017-05-30 23:51:23', -- datetime
some_val = '689728' -- varchar
This code was working fine before, but since I've upgraded I now get the following couple of errors...
Error 1 (is_some_toggle is a tinyint and is not defined in the query above, it is assumed that MariaDB would just insert a 0)
Field 'is_some_toggle' doesn't have a default value
Error 2 (after I set the default value to is_some_toggle)
Incorrect integer value: '' for column 'phone_number' at row 1
I'm guessing this is a feature, not a bug. I've looked through their changelogs for 10.2 series and I'm not seeing anything jump out, but there's a lot so I could have missed it. I saw a server config for OLD_SQL but that didn't seem to be what I was looking for. Any thoughts?
macOS Sierra 10.12.5 btw
CREATE TABLE `table` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(200) NOT NULL,
`phone_number` bigint(20) NOT NULL,
`some_val` varchar(6) NOT NULL,
`ts` datetime DEFAULT NULL,
`is_some_toggle` tinyint(1) NOT NULL,
PRIMARY KEY (`id`),
KEY `email_code` (`email`(15),`some_val`),
KEY `phone_number_code` (`phone_number`,`some_val`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
Looks like going through the changelog VERY slowly worked for me.
sql_mode was updated as was outlined in this article.
Option | Old default value | New default value
sql_mode | NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION | STRICT_TRANS_TABLES, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION
I changed it back to the default and I'm good as gold.
For one of my custom module I have following sql setup script
$installer = $this;
$installer->startSetup();
$installer->run("
CREATE TABLE {$this->getTable('wholesale')} (
`wholesale_id` int(11) unsigned NOT NULL auto_increment,
`title` varchar(255) NOT NULL default '',
`percentage` float(5,3) NOT NULL,
`status` smallint(6) NOT NULL default '0',
`created_time` datetime NULL,
`update_time` datetime NULL,
PRIMARY KEY (`wholesale_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
$installer->endSetup();
The value passed to this percentage` float(5,3) NOT NULL, column is saving with decimal but always with 00 for example. If I save a value 10.23 it save in database as 10.00.
Please help
I ran into the same issue. After clearing the cache with "Flush Magento cache", it started to save properly. In my case, I had altered the column and it was being cached.
I truncated the table and inserted one record manually and it worked for me.
I am not sure why this happened but this worked for me.
I have approx 70000 products in my catalog.Whenever I do some changes on product level,it takes lot of time to update the change.
Check & follow these steps
To clear all the locks for re-indexing locate var/locks directory and remove all files under this directory.
Now, login to your MysQSL/phpMyAdmin to run the following MySQL query (Ensure that your have taken full backup before committing this MySQL query):
DELETE cpop.* FROM catalog_product_option_price AS cpop INNER
JOIN catalog_product_option AS cpo ON cpo.option_id =
cpop.option_id WHERE cpo.type = 'checkbox' OR cpo.type =
'radio' OR cpo.type = 'drop_down';
and
DELETE cpotp.* FROM catalog_product_option_type_price AS cpotp
INNER JOIN catalog_product_option_type_value AS cpotv ON
cpotv.option_type_id = cpotp.option_type_id INNER JOIN
catalog_product_option AS cpo ON cpotv.option_id = cpo.option_id
WHERE cpo.type <> 'checkbox' AND cpo.type <> 'radio' AND
cpo.type <> 'drop_down'
Log back in to your Magento Admin panel and go to System tab > Index Management hit index again and you will notice no such errors will appear again. You can follow these same steps again if re-indexing stops in future to resolve Magento ReIndexing issues.
Use three step in magento database (mysql) and Solve Re-indexing Problem
First step:
DROP TABLE IF EXISTS `index_process_event`;
DROP TABLE IF EXISTS `index_event`;
DROP TABLE IF EXISTS `index_process`;
Second step:
CREATE TABLE `index_event` (
`event_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`type` VARCHAR(64) NOT NULL,
`entity` VARCHAR(64) NOT NULL,
`entity_pk` BIGINT(20) DEFAULT NULL,
`created_at` DATETIME NOT NULL,
`old_data` MEDIUMTEXT,
`new_data` MEDIUMTEXT,
PRIMARY KEY (`event_id`),
UNIQUE KEY `IDX_UNIQUE_EVENT` (`type`,`entity`,`entity_pk`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
CREATE TABLE `index_process` (
`process_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`indexer_code` VARCHAR(32) NOT NULL,
`status` ENUM('pending','working','require_reindex') NOT NULL DEFAULT 'pending',
`started_at` DATETIME DEFAULT NULL,
`ended_at` DATETIME DEFAULT NULL,
`mode` ENUM('real_time','manual') NOT NULL DEFAULT 'real_time',
PRIMARY KEY (`process_id`),
UNIQUE KEY `IDX_CODE` (`indexer_code`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
Third step:
INSERT INTO `index_process`(`process_id`,`indexer_code`,`status`,`started_at`,`ended_at`,`mode`) VALUES (1,'catalog_product_attribute','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(2,'catalog_product_price','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(3,'catalog_url','pending','2010-02-13 19:12:15','2010-02-13 19:12:15','real_time'),(4,'catalog_product_flat','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(5,'catalog_category_flat','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(6,'catalog_category_product','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(7,'catalogsearch_fulltext','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(8,'cataloginventory_stock','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time');
CREATE TABLE `index_process_event` (
`process_id` INT(10) UNSIGNED NOT NULL,
`event_id` BIGINT(20) UNSIGNED NOT NULL,
`status` ENUM('new','working','done','error') NOT NULL DEFAULT 'new',
PRIMARY KEY (`process_id`,`event_id`),
KEY `FK_INDEX_EVNT_PROCESS` (`event_id`),
CONSTRAINT `FK_INDEX_EVNT_PROCESS` FOREIGN KEY (`event_id`) REFERENCES `index_event` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_INDEX_PROCESS_EVENT` FOREIGN KEY (`process_id`) REFERENCES `index_process` (`process_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=INNODB DEFAULT CHARSET=utf8;