{
"query": {
"bool": {
"must": [
{
"terms": {
"id": [
111,
222,
333
]
}
},
{
"bool": {
"should": [
{
"match": {
"name": {
"query": "курс"
}
}
},
{
"nested": {
"path": "tags",
"query": {
"match": {
"tags.name": {
"query": "курс"
}
}
}
}
}
]
}
}
]
}
}
}
SELECT *
FROM user as u
WHERE (
DATE_FORMAT(u.birthday, '%m%d') >= (
SELECT
CONCAT(LEFT(`h`.`date_start`, 2), RIGHT(`h`.`date_start`, 2))
FROM horoscope h
WHERE h.name = 'Capricorn'
) AND DATE_FORMAT(u.birthday, '%m%d') <= 1231
) OR (
DATE_FORMAT(u.birthday, '%m%d') >= 101 AND DATE_FORMAT(u.birthday, '%m%d') <= (
SELECT
CONCAT(LEFT(`h`.`date_end`, 2), RIGHT(`h`.`date_end`, 2))
FROM horoscope h
WHERE h.name = 'Capricorn'
)
);
echo -en "\n${GREEN}Начало импорта...${NORMAL}\n\n"
CURRENT_DIR=`pwd`
function importDumpFileToVagrant {
cd ${CURRENT_DIR}
pwd
echo ${DUMP_FILE_NAME}
if [[ -f ${DUMP_FILE_NAME} ]]
then
pv ${CURRENT_DIR}/${DUMP_FILE_NAME} | mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -D${MYSQL_DB_NAME} -u${MYSQL_USER} -p${MYSQL_PASS}
rm ${DUMP_FILE_NAME}
echo -en "${GREEN}Импортирование прошло успешно! =(${NORMAL}\n";
else
echo -en "${RED}Файл дампа БД не найден! =(${NORMAL}\n";
fi
}
echo -en "${YELLOW}Создаем дамп на сервере...${NORMAL}\n"
ssh ${SSH_LOGIN}@${SSH_HOST} 'bash /var/www/hlamada.ru/server/backup.sh -m db'
echo -en "${GREEN}Дамп успешно создан и отправлен на FTP сервер...${NORMAL}\n"
echo -en "${YELLOW}Мотируем FTP как диск в папку '${PATH_TO_MOUNT}' ${NORMAL}\n"
fusermount -u ${PATH_TO_MOUNT}
curlftpfs ${FTP_LOGIN}:${FTP_PASS}@${FTP_HOST} ${PATH_TO_MOUNT}
echo -en "${GREEN}Монтирование прошло успешно! '${CYAN}${PATH_TO_MOUNT}${NORMAL}' \n"
cd ${PATH_TO_MOUNT}/hlamada.ru/
DIR_NAME=`ls | tail -1`
cd ${DIR_NAME}
FILE_NAME=`ls | tail -1`
echo -en "${YELLOW}Распаковка дампа...${NORMAL}\n"
tar -xvzf ${PATH_TO_MOUNT}/hlamada.ru/${DIR_NAME}/${FILE_NAME} -C ${CURRENT_DIR}
echo -en "\n${GREEN}Распаковка дампа прошла успешно!\nНаходится в '${CYAN}${CURRENT_DIR}/${DUMP_FILE_NAME}${YELLOW}'${NORMAL}\n"
importDumpFileToVagrant
echo -en "\n${GREEN}Конец импорта!\n\n"
/**
* {@inheritDoc}
*/
protected function _validationRules()
{
$qntValidSelect = new Zend_Db_Select(Zend_Db_Table_Abstract::getDefaultAdapter());
$qntValidSelect
->from(OptionTableMap::TABLE_NAME)
->where('Name = ?', $this->getData('name'))
->where('ThingId = ?', $this->getData('thingId'));
return [
'name' => [
self::PRESENCE => self::PRESENCE_REQUIRED,
'NotEmpty',
[
'StringLength',
['max' => 255],
],
],
'slug' => [
self::PRESENCE => self::PRESENCE_REQUIRED,
'NotEmpty',
[
'StringLength',
['max' => 255],
],
],
'thingId' => [
self::PRESENCE => self::PRESENCE_REQUIRED,
'NotEmpty',
[
'StringLength',
['max' => 11],
],
[
'Regex',
['pattern' => '/^[1-9]\d*$/'],
],
[
'DB_RecordExists',
[
'table' => ThingTableMap::getTableMap()->getName(),
'field' => ThingTableMap::getTableMap()->getColumn('id')->getName(),
]
],
],
'select' => [
[
'Regex',
['pattern' => '/^[01]*$/'],
],
],
'accounting' => [
[
'Regex',
['pattern' => '/^[01]*$/'],
],
],
];
}