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
00035 class Mage_Dataflow_Model_Mysql4_Import extends Mage_Core_Model_Mysql4_Abstract
00036 {
00037
00038 protected function _construct()
00039 {
00040 $this->_init('dataflow/import', 'import_id');
00041 }
00042
00043 public function select($sessionId)
00044 {
00045 return $this->_getReadAdapter()->select()
00046 ->from($this->getMainTable())
00047 ->where('session_id=?', $sessionId)
00048 ->where('status=?', 0);
00049 }
00050
00051 public function loadBySessionId($sessionId, $min = 0, $max = 100)
00052 {
00053 if (!is_numeric($min) || !is_numeric($max)) {
00054 return array();
00055 }
00056 $read = $this->_getReadAdapter();
00057 $select = $read->select()->from($this->getTable('dataflow/import'), '*')
00058 ->where('import_id between '.(int)$min.' and '.(int)$max)
00059 ->where('status=?', '0')
00060 ->where('session_id=?', $sessionId);
00061 return $read->fetchAll($select);
00062 }
00063
00064 public function loadTotalBySessionId($sessionId)
00065 {
00066 $read = $this->_getReadAdapter();
00067 $select = $read->select()->from($this->getTable('dataflow/import'),
00068 array('max'=>'max(import_id)','min'=>'min(import_id)', 'cnt'=>'count(*)'))
00069 ->where('status=?', '0')
00070 ->where('session_id=?', $sessionId);
00071 return $read->fetchRow($select);
00072 }
00073
00074 public function loadById($importId)
00075 {
00076 $read = $this->_getReadAdapter();
00077 $select = $read->select()->from($this->getTable('dataflow/import'),'*')
00078 ->where('status=?', 0)
00079 ->where('import_id=?', $importId);
00080 return $read->fetchRow($select);
00081 }
00082
00083 }