public function testListIntegers() { $this->assertEquals('1,2,3,4,5', Model::listIntegers(array('1', '2', '3', '4', '5'))); }
/** * Clear links for object list * @param string $objectName * @param array $objectsIds */ public function clearLinksFor($objectName, array $objectsIds) { $this->_db->delete($this->table(), '`src` = ' . $this->_db->quote($objectName) . ' AND `src_id` IN(' . Model::listIntegers($objectsIds) . ')'); }
/** * Get blocks map from object vesrion * * @param integer $pageId * @param integer $version * @return array */ public function extractBlocks($pageId, $version) { $vcModel = Model::factory('Vc'); $data = $vcModel->getData('page', $pageId, $version); if (!isset($data['blocks']) || empty($data['blocks'])) { return array(); } $data = unserialize($data['blocks']); if (empty($data)) { return array(); } $ids = array(); $info = array(); foreach ($data as $place => $items) { if (!empty($items)) { foreach ($items as $index => $config) { $ids[] = $config['id']; } $sql = $this->_dbSlave->select()->from($this->table())->where('`id` IN(' . Model::listIntegers($ids) . ')'); $info = $this->_dbSlave->fetchAll($sql); } } if (!empty($info)) { $info = Utils::rekey('id', $info); } foreach ($data as $place => $items) { if (!empty($items)) { foreach ($items as $index => $config) { if (isset($info[$config['id']])) { $data[$place][$index] = $info[$config['id']]; $data[$place][$index]['place'] = $place; } } } } return $data; }