getDB(); $db->isTransactionSupported() and $db->startTransaction(); $keyfields = ['id' => $gallery->id]; $oldSearch = $db->table('m_mcms#gallery_gallerys')->select($keyfields); $doUpdate = $oldSearch->getRowCount() > 0; $oldSearch->close(); unset($oldSearch); // transient fields and sequence fields needs to be excluded $ignore = ['id']; if ($doUpdate) { $db->table('m_mcms#gallery_gallerys')->update($gallery, ['id' => $gallery->id], $ignore); } else { $db->table('m_mcms#gallery_gallerys')->insert($gallery, $ignore); $gallery->id = $db->getInsertId('id'); } $db->isTransactionSupported() and $db->commit(); return $gallery; } /** * Fetches an entry * * @return \MCMS\_\Modx\MCMS\Gallery\_\Model\Gallery the stored entry */ public static function getGallery($siteId,$instance,$id) { $db = System::getInstance()->getDB(); $_class = '\\MCMS\\_\\Modx\\MCMS\\Gallery\\_\\Model\\Gallery'; $result = $db->table('m_mcms#gallery_gallerys')->getObject(['site_id' => $siteId,'instance' => $instance,'id' => $id], false, $_class); return $result; } /** * Deletes an entry */ public static function removeGallery(\MCMS\_\Modx\MCMS\Gallery\_\Model\Gallery $gallery) { $db = System::getInstance()->getDB(); $db->isTransactionSupported() and $db->startTransaction(); $db->table('m_mcms#gallery_gallerys')->delete(['id' => $gallery->id]); $db->isTransactionSupported() and $db->commit(); } // public static function storePic(MCMS\_\Modx\MCMS\Gallery\_\Model\Gallery $gallery,MCMS\_\Modx\MCMS\Gallery\_\Model\PicInfo $info,$data) {} // public static function updatePicBinData(MCMS\_\Modx\MCMS\Gallery\_\Model\PicInfo $info,$data) {} // public static function getPicList($gallery,$page,$pageSize) {} // public static function getPicInfo($picId) {} // public static function getPicBinData($picId) {} // public static function removePic(MCMS\_\Modx\MCMS\Gallery\_\Model\Gallery $gallery,MCMS\_\Modx\MCMS\Gallery\_\Model\PicInfo $info) {} }