magento 在Magento中使用自己写的SQL语句
Magento的Models
和Collection
很强大,使用它们可以很方便的查询和操作数据库。但是有些场合,因为一些特殊需求或对Magento的了解不够深,可能会需要自己手写SQL语句来查询和操作数据库。以下分别是读写数据库的代码。
// For Read
// fetch read database connection that is used in Mage_Core module
$read= Mage::getSingleton('core/resource')->getConnection('core_read');
$value=$read->query("SE...");
$row = $value->fetch();
print_r($row); // As Array
// For Write
// fetch write database connection that is used in Mage_Core module
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
// now $write is an instance of Zend_Db_Adapter_Abstract
$write->query("insert into tablename values ('aaa','bbb','ccc')");
相关文档:
select * from ((select bill.id billId,bach.riskRate risk,bach.assureRate assure from AcptBillInfo bill,AcptBach bach where bill.acptBatchId=bach.id and bill.rgctId=? )abach left outer join AcptSignMoney sig on abach.billId = sig.billId) ......
SQL字符串函数http://www.cnblogs.com/virusswb/archive/2008/09/10/1288576.html
select语句中只能使用sql函数对字段进行操作(链接sql server),
select 字段1 from 表1 where 字段1.IndexOf("云")=1;
这条语句不对的原因是indexof()函数不是sql函数,改成sql对应的函数就可以了。
left()是sql函数。
select 字 ......
本文转自:http://industry.ccidnet.com/art/1106/20070514/1080519_1.html
本文是SQL Server SQL语句优化系列文章的第一篇。该系列文章描述了在Micosoft’s SQLServer2000关系数据库管理系统中优化SELECT语句的基本技巧,我们讨论的技巧可在Microsoft's SQL Enterprise Manager或 Microsoft SQL Query Anal ......
现象:
我的电脑--管理--服务--mssqlserver 服务 --启动
报错,1068,
或者,sqlserver 配置管理器中SqlServer 主服务启动 报错 提示说依存的服务或者组件没有启动,
原因:我是菜鸟,不太理解到底什么原因,但是找到了解决方法
解决方法:
SqlSe ......