vtiger 6 can't add user - php

When I try and create a user, it goes to a blank white page. When I go back to crm, no user was created. Is there a fix?
so for example there was another issue where webforms did not want to save. so i applied a fix i found somewhere which was to add a database table. the code for that is below. so i was looking for similar help with this new issue above. don't know if it's going to be a mysql modification or a php modification, but hopefully someone knows something.
CREATE TABLE `vtiger_webforms_field` (
`id` int(19) NOT NULL AUTO_INCREMENT,
`webformid` int(19) NOT NULL,
`fieldname` varchar(50) NOT NULL,
`neutralizedfield` varchar(50) NOT NULL,
`defaultvalue` varchar(200) DEFAULT NULL,
`required` int(10) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `webforms_webforms_field_idx` (`id`),
KEY `fk_1_vtiger_webforms_field` (`webformid`),
KEY `fk_2_vtiger_webforms_field` (`fieldname`),
CONSTRAINT `fk_1_vtiger_webforms_field` FOREIGN KEY (`webformid`) REFERENCES `vtiger_webforms` (`id`) ON DELETE CASCADE,
CONSTRAINT `fk_3_vtiger_webforms_field` FOREIGN KEY (`fieldname`) REFERENCES `vtiger_field` (`fieldname`) ON DELETE CASCADE
)

Related

Doctrine exception - [Doctrine\ORM\Mapping\MappingException]

Hi I'm new in symfony.
I'm trying to generate entities from an existing database with doctrine.
When I run this command:
php bin/console doctrine:mapping:import --force AppBundle xml
I get this exception :
[Doctrine\ORM\Mapping\MappingException]
Property "shop" in "Bug" was already declared, but it must be declared only once
I have tried to search other solutions, but I didn't find anythings.
How can I solve this problem?
This is how mysql workbench creates my table:
CREATE TABLE IF NOT EXISTS `db`.`bug` (
`id_bug` INT(11) NOT NULL AUTO_INCREMENT,
`bug_name` VARCHAR(200) NOT NULL,
`comment` VARCHAR(1000) NOT NULL,
`status` INT(11) NOT NULL DEFAULT '0',
`customer_id` VARCHAR(255) CHARACTER SET 'utf8' NOT NULL,
`shop_id` VARCHAR(255) CHARACTER SET 'utf8' NOT NULL,
`admin_id` VARCHAR(255) CHARACTER SET 'utf8' NOT NULL,
PRIMARY KEY (`id_bug`),
INDEX `fk_bug_customer1_idx1` (`customer_id` ASC),
INDEX `fk_bug_shop1_idx` (`shop_id` ASC),
INDEX `fk_bug_admin1_idx1` (`admin_id` ASC),
CONSTRAINT `fk_bug_customer1`
FOREIGN KEY (`customer_id`)
REFERENCES `db`.`customer` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_bug_shop1`
FOREIGN KEY (`shop_id`)
REFERENCES `db`.`shop` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_bug_admin1`
FOREIGN KEY (`admin_id`)
REFERENCES `db`.`admin` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
I'm working in symfony 3.3, mysql and php7.
Thanks.
There were two problem:
First of all there was a relaction duplicated on the same enitity
It was not the only problem. We noticed that in doctrine occours problems when there is a primary key that is also a foreign key, so we added a new field id for the primary key.

Why is primary key a duplicate [duplicate]

This question already has answers here:
MySQL 1062 - Duplicate entry '0' for key 'PRIMARY'
(9 answers)
Closed 6 years ago.
I am building a CRUD app in PHP & MySql. It uses two tables, called users and medical_records:
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`username` varchar(255) NOT NULL,
`first_name` varchar(255) NOT NULL,
`last_name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(1024) NOT NULL,
`validation_code` text NOT NULL,
`active` tinyint(1) NOT NULL,
`telefon` varchar(255) DEFAULT NULL,
`oras` varchar(255) DEFAULT NULL,
`adresa` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE medical_records (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`fo` VARCHAR(255),
`condition` VARCHAR(255),
`transfer` VARCHAR(255),
`memo` text(1024),
`body_temperature` VARCHAR(255),
PRIMARY KEY (`id`),
CONSTRAINT FK_medical_records_1
FOREIGN KEY (user_id) REFERENCES users(id)
ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
The "business logic" of these tables is: every user has one (only one) medical record.
I used and tested the application when it only had the users table. Register and login worked fine, so I conclude that the problem's source can't be the application's (PHP) code.
I later doped the users table and added the 2 fresh tables the application now uses (users and medical_records).
At this moment whenever I try to register a second user, I get the error:
QUERY FAILED: Duplicate entry '0' for key 'PRIMARY'
This happens despite the fact that both tables have auto incremented primary keys. What could be the explanation of that?
the id in the users table is not set to AUTO_INCREMENT. that's why this happens.

Why won't my foreign key create in MySQL?

I've tried many different ways to create table with a foreign key and trying to insert into phpMyAdmin. However, it just not working as I was expected.
Here are what I've so far:
CREATE TABLE user (
user_id BIGINT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
user_name VARCHAR(50) NOT NULL,
user_password VARCHAR(50) NOT NULL);
This works perfectly fine. However, if I try to add a table with a foreign key thus, it refuses to create:
CREATE TABLE article (
article_id INT(20) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
article_title VARCHAR(100) NOT NULL,
article_content VARCHAR(1000) NOT NULL,
user_id INT(10) NOT NULL,
FOREIGN KEY (user_id) REFERENCES user (user_id));
This would not work as expected and would not add the table to the MySQL database. I get this error:
Cannot add foreign key constraint
How can I fix it?
We discovered in the comments that if a primary key is defined thus:
user_id BIGINT(10) UNSIGNED
then a foreign key like this will not work, since it needs to match on signedness (and I think type too):
user_id INT(10) NOT NULL
This works fine:
user_id BIGINT(10) UNSIGNED NOT NULL
Here's a Fiddle to demonstrate it working.

Nothing changes when i try to add Check Constraint in my Table

I am trying to add check constraint in my table that prevents adding more data into a table if the sum of rows shop_id is greater than 3. I have written the following code and its just not working. Kindly check this and guide me.
ALTER TABLE kinect_temp_data
ADD CONSTRAINT my_const CHECK (sum(distinct(shop_id))<3)
The above query runs successful,but it does not create any effect and i can still able to add more rows, and when i query this, it display that no check constraint was added.
SHOW CREATE TABLE kinect_temp_data
Output
CREATE TABLE `kinect_temp_data` (
`cart_number` int(11) NOT NULL AUTO_INCREMENT,
`product_id` varchar(50) NOT NULL,
`shop_id` varchar(50) NOT NULL,
`product_name` varchar(50) NOT NULL,
`item_number` varchar(50) NOT NULL,
`image1_path` varchar(50) NOT NULL,
`image2_path` varchar(50) NOT NULL,
`image3_path` varchar(50) NOT NULL,
`price` int(11) NOT NULL,
PRIMARY KEY (`cart_number`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1
Kindly check this and guide me what i am doing wring here.
Thanks.
MySQL don't support check constraints -- they are ignored.
But you can use BEFORE INSERT and BEFORE UPDATE triggers to realize such functionality.
There is good explanation

Foreign Key constraints in MySQL

I am a newbie to PHP. I have been given the code snippet below as homework:
CREATE TABLE `admin_log` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`statusdate` DATETIME DEFAULT NULL,
`type` INT(11) DEFAULT NULL
PRIMARY KEY (`id`)
) ENGINE=MYISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin
Why will it not be possible to set up any foreign key constraints using this table?
I have done some research on Google and I cant find a reason why foreign key constraints are not possible. Please help
You can do that like this :
CREATE TABLE `admin_log` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`statusdate` DATETIME DEFAULT NULL,
`type` INT(11) DEFAULT NULL,
INDEX (type),
FOREIGN KEY (type)
REFERENCES type(id)
ON UPDATE CASCADE ON DELETE RESTRICT,
PRIMARY KEY (`id`)
) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=latin
Notice the engine INNODB insetad of MYISAM which doesn't permit foreign key.
Or using MySQLAdmin in the "structure" tab, click on the "relationals view" link below the table description.
Even it has been mentioned on comment before -- just to make it more prominent: MyISAM is not supporting foreign keys. So you will need to change the engine of your table to e.g. INNODB if possible.

Categories