cakephp中的传递函数请参阅我的解释
请帮助我完成我的简单的 cakephp 应用程序。
我有一个 products_warehouses 表:
--
-- Table structure for table `products_warehouses`
--
CREATE TABLE IF NOT EXISTS `products_warehouses` (
`id` int(5) NOT NULL auto_increment,
`product_id` int(5) NOT NULL,
`buyprice` decimal(8,2) NOT NULL,
`sellprice` decimal(8,2) NOT NULL,
`date_received` date NOT NULL,
`total_stock_received` int(3) NOT NULL,
`stock_on_hand` int(3) NOT NULL,
`stock_to_transfer` int(3) default NULL,
`created` datetime NOT NULL,
`modified` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
我想要的是,我有一个转移功能,以便当我转移物品时。它将自动转到 products_showrooms 表,并且仓库中的 stock_to_tranfer 字段将添加到 products_showrooms 表中默认为 0 的 stock_received 中:
这是 products_showrooms 表,
--
-- Table structure for table `products_showrooms`
--
CREATE TABLE IF NOT EXISTS `products_showrooms` (
`product_warehouse_id` int(5) NOT NULL,
`stock_on_hand` int(2) NOT NULL,
`stock_received` int(2) NOT NULL,
`date_received` date NOT NULL,
PRIMARY KEY (`product_warehouse_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
任何人都可以帮助我吗?这些表应该有关系吗?
有人可以为我提供 Transfer() 函数的正确代码吗? 我应该在这两个表的模型和控制器中放入什么?..
谢谢..请帮助我。
please help me with my simple cakephp application.
i have a products_warehouses table:
--
-- Table structure for table `products_warehouses`
--
CREATE TABLE IF NOT EXISTS `products_warehouses` (
`id` int(5) NOT NULL auto_increment,
`product_id` int(5) NOT NULL,
`buyprice` decimal(8,2) NOT NULL,
`sellprice` decimal(8,2) NOT NULL,
`date_received` date NOT NULL,
`total_stock_received` int(3) NOT NULL,
`stock_on_hand` int(3) NOT NULL,
`stock_to_transfer` int(3) default NULL,
`created` datetime NOT NULL,
`modified` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
what i want is, i have a transfer function so that when i transfer items. it would automatically go to products_showrooms table and the stock_to_tranfer field from warehouse would be added to the stock_received which is 0 in default from the products_showrooms table:
here is the products_showrooms table
--
-- Table structure for table `products_showrooms`
--
CREATE TABLE IF NOT EXISTS `products_showrooms` (
`product_warehouse_id` int(5) NOT NULL,
`stock_on_hand` int(2) NOT NULL,
`stock_received` int(2) NOT NULL,
`date_received` date NOT NULL,
PRIMARY KEY (`product_warehouse_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
can anyone help me with this?. should these tables have a relationship?.
can someone provide me with the right codes for a transfer() function?.
what should i put in the models and controllers of these two tables?..
thank you.. please help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您需要将
product_warehouse_id
重命名为products_warehouse_id
。然后从食谱中学习关系类型。尝试自己编写代码,如果您无法使其正常工作,请提出问题。First you will need to rename
product_warehouse_id
toproducts_warehouse_id
. Then study relationship types from the cookbook. Try to put some effort in writing the code yourself and if you will not get it working then ask the question.