magento数据库处理的一些方法
2012-02-23 11:35
204 查看
<?php
//打印用户
$resource = Mage::getSingleton('core/resource');
$conn = $resource->getConnection('core_read');
$results = $conn->query('SELECT * FROM admin_user')->fetchAll();
echo '<pre>';
var_export($results);
echo '</pre>';
?>
<?php
//打印session
$singleton = Mage::getSingleton('catalog/session');
echo '<pre>';
var_export($singleton->debug());
echo '</pre>';
?>
<?php
$conf = array(
'host' => 'localhost',
'username' => 'root',
'password' => 'pwd',
'dbname' => 'wordpress' // you can any database name here
);
$_resource = Mage::getSingleton('core/resource');
//Creating new connection to new server and new database
$_conn = $_resource->createConnection('customConnection',
'pdo_mysql', $conf);
$results = $_conn->query('SELECT * FROM wp_posts')->fetchAll();
echo '<pre>';
print_r($results);
echo '</pre>';
?>
<?php
//连接数据库
$conf = array(
'host' => 'localhost',
'username' => 'root',
'password' => '',
'dbname' => 'hhl' // you can any database name here
);
$_resource = Mage::getSingleton('core/resource');
//Creating new connection to new server and new database
$_conn = $_resource->createConnection('customConnection',
'pdo_mysql', $conf);
$results = $_conn->query('SELECT * FROM hhl_activety')->fetchAll();
echo '<pre>';
print_r($results);
echo '</pre>';
?>
//打印用户
$resource = Mage::getSingleton('core/resource');
$conn = $resource->getConnection('core_read');
$results = $conn->query('SELECT * FROM admin_user')->fetchAll();
echo '<pre>';
var_export($results);
echo '</pre>';
?>
<?php
//打印session
$singleton = Mage::getSingleton('catalog/session');
echo '<pre>';
var_export($singleton->debug());
echo '</pre>';
?>
<?php
$conf = array(
'host' => 'localhost',
'username' => 'root',
'password' => 'pwd',
'dbname' => 'wordpress' // you can any database name here
);
$_resource = Mage::getSingleton('core/resource');
//Creating new connection to new server and new database
$_conn = $_resource->createConnection('customConnection',
'pdo_mysql', $conf);
$results = $_conn->query('SELECT * FROM wp_posts')->fetchAll();
echo '<pre>';
print_r($results);
echo '</pre>';
?>
<?php
//连接数据库
$conf = array(
'host' => 'localhost',
'username' => 'root',
'password' => '',
'dbname' => 'hhl' // you can any database name here
);
$_resource = Mage::getSingleton('core/resource');
//Creating new connection to new server and new database
$_conn = $_resource->createConnection('customConnection',
'pdo_mysql', $conf);
$results = $_conn->query('SELECT * FROM hhl_activety')->fetchAll();
echo '<pre>';
print_r($results);
echo '</pre>';
?>
相关文章推荐
- 数据库访问的一些公共的方法01-执行SQL的事务处理
- 数据库处理海量数据时的一些优化查询速度方法
- 数据库连接字符串的处理方法!加密解密连接字符串。
- 关于图片处理的一些方法
- C# 处理word的一些方法
- VC 处理数据库datetime字段的方法
- C#连接数据库的一些鲜为人知的方法
- 一些SQL 处理字符串的方法
- 数据库日志文件过大的处理方法
- 时间日期的一些处理方法
- 图片的一些效果处理方法
- C#有关时间处理的一些方法,两个日期间相差的天、小时、分钟、月数等
- 关于对象数据库 DB4O 的一些BUG以及如何应对的方法
- MTK的一些问题的处理方法
- c#中math各种函数对整值不同的处理方法及一些说明(优化分页的时候特别用到)
- MYSQL导出数据库的一些方法
- FastJson一些常见方法(API):处理JSON变得好简单
- Mysql处理海量数据时的一些优化查询速度方法
- 数据库访问的一些公共的方法02-返回DataReader,DataSet,DataTable等对象
- 黑马程序员<.net中安全处理字符串的一些方法>