本文整理汇总了PHP中Varien_Db_Select::insertFromSelect方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Db_Select::insertFromSelect方法的具体用法?PHP Varien_Db_Select::insertFromSelect怎么用?PHP Varien_Db_Select::insertFromSelect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Db_Select
的用法示例。
在下文中一共展示了Varien_Db_Select::insertFromSelect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertFromSelect
/**
* Insert data from select statement of read adapter to
* destination table related with index adapter
*
* @param Varien_Db_Select $select
* @param string $destTable
* @param array $columns
* @param bool $readToIndex data migration direction (true - read=>index, false - index=>read)
* @return Mage_Index_Model_Resource_Abstract
*/
public function insertFromSelect($select, $destTable, array $columns, $readToIndex = true)
{
if ($readToIndex) {
$from = $this->_getWriteAdapter();
$to = $this->_getIndexAdapter();
} else {
$from = $this->_getIndexAdapter();
$to = $this->_getWriteAdapter();
}
if ($from === $to) {
$query = $select->insertFromSelect($destTable, $columns);
$to->query($query);
} else {
$stmt = $from->query($select);
$data = array();
$counter = 0;
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$data[] = $row;
$counter++;
if ($counter > 2000) {
$to->insertArray($destTable, $columns, $data);
$data = array();
$counter = 0;
}
}
if (!empty($data)) {
$to->insertArray($destTable, $columns, $data);
}
}
return $this;
}
示例2: getInsertFromSelectUsingAnalytic
/**
*
* Returns Insert From Select On Duplicate query with analytic functions
*
* @param Varien_Db_Select $select
* @param string $table
* @param array $table
* @return string
*/
public function getInsertFromSelectUsingAnalytic(Varien_Db_Select $select, $table, $fields)
{
return $select->insertFromSelect($table, $fields);
}