Coder Social home page Coder Social logo

Comments (10)

mevdschee avatar mevdschee commented on June 3, 2024

@ErikV88 tested this on MySQL and it works, could it be that you forgot to add:

ALTER TABLE posts ADD PRIMARY KEY id (id);`

Where 'posts' is your table?

from php-crud-api.

mevdschee avatar mevdschee commented on June 3, 2024

Please let me know whether or not this solves the issue.

from php-crud-api.

mevdschee avatar mevdschee commented on June 3, 2024

closed due to inactivity

from php-crud-api.

ErikV88 avatar ErikV88 commented on June 3, 2024

Sorry, It fail when calling a view . We need a uniq table It also be cool if we add a table with synoynm /alias for all object . DatabaseObjects what have metadata to db objects , also sp view , and tables

from php-crud-api.

mevdschee avatar mevdschee commented on June 3, 2024

Please post your table definition, so I can help you. Use:

show table posts;

Where 'posts' is the table you are using.

from php-crud-api.

ErikV88 avatar ErikV88 commented on June 3, 2024
CREATE TABLE IF NOT EXISTS `BasketProducts` (
  `BasketID` int(11) NOT NULL,
  `ProductID` int(11) NOT NULL,
  `NummerOfProducts` int(11) NOT NULL DEFAULT '1',
  `PrimKey` varchar(64) NOT NULL DEFAULT '',
  PRIMARY KEY (`PrimKey`),
  KEY `WebShop_BasketProductsProductID` (`ProductID`,`BasketID`),
  KEY `IX_ProductBasket` (`BasketID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



DROP TRIGGER IF EXISTS `IXBasketProducts`;
DELIMITER //
CREATE TRIGGER `IXBasketProducts` BEFORE INSERT ON `BasketProducts`
 FOR EACH ROW SET NEW.PrimKey=UUID()
//
DELIMITER ;

ALTER ALGORITHM=UNDEFINED DEFINER=`myUser`@`localhost` SQL SECURITY DEFINER VIEW `aviw_BasketProducts` AS 
    SELECT `P`.`ID` AS `ID`,`P`.`Name` AS `Name`,`P`.`Price` AS `Price`,`P`.`Description` AS `Description`,`BP`.`NummerOfProducts` AS `NummerOfProducts`,`BP`.`PrimKey`     AS `PrimKey`,(`P`.`Price` * `BP`.`NummerOfProducts`) AS     `TotalPrice` 
    FROM (`BasketProducts` `BP`     
      INNER JOIN WebShop_Products` `P` on((`P`.`ID` = `BP`. `ProductID`))) 
      GROUP BY `BP`.`BasketID`,`BP`.`ProductID`

from php-crud-api.

mevdschee avatar mevdschee commented on June 3, 2024

I think your view has either none or two primary keys. Check the output of:

SELECT COLUMN_NAMEFROMINFORMATION_SCHEMA.COLUMNSWHERECOLUMN_KEY= 'PRI' ANDTABLE_NAME = 'aviw_BasketProducts';

Probably it does not show one single primary key (1pk) on the view (as is required).

from php-crud-api.

mevdschee avatar mevdschee commented on June 3, 2024

Tried to simulate your case and even without join there are no primary keys defined for views (probably by definition). This means that in order to expose full crud on a view we need another method to find the primary key. Fallback to the name "id" comes to mind as a possible solution or to default to the first column of the view.

from php-crud-api.

ErikV88 avatar ErikV88 commented on June 3, 2024

I find a solution to it ... in my js lib , my object now the uniqtable of the view... Then i can call the view if update and delete or update . but if select then the view 👍

from php-crud-api.

mevdschee avatar mevdschee commented on June 3, 2024

Fallback to the name "id" comes to mind as a possible solution or to default to the first column of the view.

This is now implemented

from php-crud-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.