Пожалуйста, войдите здесь. Часто задаваемые вопросы О нас
Задайте Ваш вопрос

История изменений [назад]

нажмите, чтобы скрыть/показать версии 1
изначальная версия
редактировать

ответил 2012-11-27 13:32:43 +0400

meral Gravatar meral flag of Ukraine

http://pro-sip.net/

по ssh

. /etc/amportal.conf
mysql asterisk -u $AMPDBUSER -p$AMPDBPASS

дальше на sql пишите запрос вот такого вида

select ids.id,
(select data from sip where keyword='callerid' and id=ids.id) as callerid,
(select data from sip where keyword='secret' and id=ids.id) as secret,
(select data from sip where keyword='callgroup' and id=ids.id) as callgroup
  from (select distinct id from sip) ids;

ну добавляете колонки чего вам надо.

получаете вот такое

mysql> select ids.id,(select data from sip where keyword='callerid' and id=ids.id) as callerid,(select data from sip where keyword='secret' and id=ids.id) as secret,(select data from sip where keyword='callgroup' and id=ids.id) as callgroup from (select distinct id from sip) ids; +-----+--------------+-------------+-----------+ | id | callerid | secret | callgroup | +-----+--------------+-------------+-----------+ | 199 | device <199> | mtest23test | | +-----+--------------+-------------+-----------+ 1 row in set (0.00 sec)

можно сразу експортнуть в csv. смотрите

select ids.id,
(select data from sip where keyword='callerid' and id=ids.id) as callerid,
    (select data from sip where keyword='secret' and id=ids.id) as secret,
    (select data from sip where keyword='callgroup' and id=ids.id) as callgroup

INTO OUTFILE '/tmp/products.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'

from (select distinct id from sip) ids;

выполнить по sshssh(скопировать и вставить в консоль/putty)

. /etc/amportal.conf
mysql asterisk -u $AMPDBUSER -p$AMPDBPASS

дальше на sql пишите запрос вот такого вида

select ids.id,
(select data from sip where keyword='callerid' and id=ids.id) as callerid,
(select data from sip where keyword='secret' and id=ids.id) as secret,
(select data from sip where keyword='callgroup' and id=ids.id) as callgroup
  from (select distinct id from sip) ids;

ну добавляете колонки чего вам надо.

получаете вот такое

mysql> select ids.id,(select data from sip where keyword='callerid' and id=ids.id) as callerid,(select data from sip where keyword='secret' and id=ids.id) as secret,(select data from sip where keyword='callgroup' and id=ids.id) as callgroup from (select distinct id from sip) ids; +-----+--------------+-------------+-----------+ | id | callerid | secret | callgroup | +-----+--------------+-------------+-----------+ | 199 | device <199> | mtest23test | | +-----+--------------+-------------+-----------+ 1 row in set (0.00 sec)

можно сразу експортнуть в csv. смотрите

select ids.id,
(select data from sip where keyword='callerid' and id=ids.id) as callerid,
    (select data from sip where keyword='secret' and id=ids.id) as secret,
    (select data from sip where keyword='callgroup' and id=ids.id) as callgroup

INTO OUTFILE '/tmp/products.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'

from (select distinct id from sip) ids;

Проект компании "АТС Дизайн"
Asterisk® и Digium® являются зарегистрированными торговыми марками компании Digium, Inc., США.
IP АТС Asterisk распространяется под лицензией GNU GPL.