1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Catalog
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27:
28: /**
29: * Eav Mysql resource helper model
30: *
31: * @category Mage
32: * @package Mage_Catalog
33: * @author Magento Core Team <core@magentocommerce.com>
34: */
35: class Mage_Catalog_Model_Resource_Helper_Mysql4 extends Mage_Eav_Model_Resource_Helper_Mysql4
36: {
37:
38: /**
39: * Returns columns for select
40: *
41: * @param string $tableAlias
42: * @param string $eavType
43: * @return array
44: */
45: public function attributeSelectFields($tableAlias, $eavType)
46: {
47: return '*';
48: }
49:
50: /**
51: * Compare Flat style with Describe style columns
52: * If column a different - return false
53: *
54: * @param array $column
55: * @param array $describe
56: * @return bool
57: */
58: public function compareIndexColumnProperties($column, $describe)
59: {
60: $type = $column['type'];
61: if (isset($column['length'])) {
62: $type = sprintf('%s(%s)', $type[0], $column['length']);
63: } else {
64: $type = $type[0];
65: }
66: $length = null;
67: $precision = null;
68: $scale = null;
69:
70: $matches = array();
71: if (preg_match('/^((?:var)?char)\((\d+)\)/', $type, $matches)) {
72: $type = $matches[1];
73: $length = $matches[2];
74: } else if (preg_match('/^decimal\((\d+),(\d+)\)/', $type, $matches)) {
75: $type = 'decimal';
76: $precision = $matches[1];
77: $scale = $matches[2];
78: } else if (preg_match('/^float\((\d+),(\d+)\)/', $type, $matches)) {
79: $type = 'float';
80: $precision = $matches[1];
81: $scale = $matches[2];
82: } else if (preg_match('/^((?:big|medium|small|tiny)?int)\((\d+)\)?/', $type, $matches)) {
83: $type = $matches[1];
84: }
85:
86: return ($describe['DATA_TYPE'] == $type)
87: && ($describe['DEFAULT'] == $column['default'])
88: && ((bool)$describe['NULLABLE'] == (bool)$column['nullable'])
89: && ((bool)$describe['UNSIGNED'] == (bool)$column['unsigned'])
90: && ($describe['LENGTH'] == $length)
91: && ($describe['SCALE'] == $scale)
92: && ($describe['PRECISION'] == $precision);
93: }
94:
95: /**
96: * Getting condition isNull(f1,f2) IS NOT Null
97: *
98: * @param string $field1
99: * @param string $field2
100: * @return string
101: */
102: public function getIsNullNotNullCondition($field1, $field2)
103: {
104: return sprintf('%s IS NOT NULL', $this->_getReadAdapter()->getIfNullSql($field1, $field2));
105: }
106: }
107: