00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 abstract class Mage_Core_Model_Resource_Abstract
00035 {
00036 public function __construct()
00037 {
00038 $this->_construct();
00039 }
00040
00041
00042
00043
00044 abstract protected function _construct();
00045
00046
00047
00048
00049 abstract protected function _getReadAdapter();
00050
00051
00052
00053
00054 abstract protected function _getWriteAdapter();
00055
00056
00057
00058
00059
00060
00061 public function beginTransaction()
00062 {
00063 $this->_getWriteAdapter()->beginTransaction();
00064 return $this;
00065 }
00066
00067
00068
00069
00070
00071
00072 public function commit()
00073 {
00074 $this->_getWriteAdapter()->commit();
00075 return $this;
00076 }
00077
00078
00079
00080
00081
00082
00083 public function rollBack()
00084 {
00085 $this->_getWriteAdapter()->rollBack();
00086 return $this;
00087 }
00088
00089
00090
00091
00092
00093
00094
00095
00096 public function formatDate($date, $includeTime=true)
00097 {
00098 if ($date instanceof Zend_Date) {
00099 if ($includeTime) {
00100 return $date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
00101 }
00102 else {
00103 return $date->toString(Varien_Date::DATE_INTERNAL_FORMAT);
00104 }
00105 }
00106
00107 if (empty($date)) {
00108 return new Zend_Db_Expr('NULL');
00109 }
00110
00111 if (!is_numeric($date)) {
00112 $date = strtotime($date);
00113 }
00114 if ($includeTime) {
00115 return date('Y-m-d H:i:s', $date);
00116 }
00117 else {
00118 return date('Y-m-d', $date);
00119 }
00120 }
00121
00122 public function mktime($str)
00123 {
00124 return strtotime($str);
00125 }
00126 }