Jump to content

xaero

User
  • Posts

    98
  • Joined

  • Last visited

Everything posted by xaero

  1. Привет всем ———————-- id | name | prev_id ———————-- 1 | absc | 2 ———————-- 2 | dbcs | 3 ———————-- 3 | cols | 4 ———————-- 4 | noth | 0 prev_id - id предыдущий строки Можно ли select делать такой запрос который подключает как колонка предыдущий строки ?
  2. У меня имеется 2 таблиц 1. search_result 2. products хотелось бы подсчитать сколько строк находится в таблице products который у таблиц указано поля search_result.query_text SELECT s.id, s.query_text ( select count(*) from products where name concat('%', s.query_text, '%') limit 0, 1 ) as total FROM search_result AS s GROUP BY s.query_text вообще то такое возможно?
  3. Как выровнять текстовые блоки Как можно делать блоки ровным. От зависимости текста. Одного блока больше текст и остальные высота боки чтобы были ровным. http://my.jetscreenshot.com/1668/20100216-vozf-44kb.jpg
  4. xaero

    State Controller v4

    Лучше изучайте ExtJS
  5. $text = ' hallow world "nothing i fill" current "asdasd"'; нужно удалить пробелы вне кавычки ....
  6. xaero

    Календарь на php

    Посмотрите ... <html> <head> <title> Calendar </title> </head> <style> /* CALENDAR */ table.cal { border-collapse: collapse; border: 1px solid #eaeaea; } table.cal td { text-align: center; } td.center { font-weight: bold; color: #216792; } td.prev { width: 25px; text-align: center; } td.prev a { font-wegith: bold; } td.center { text-align: center; width: 100%; } td.next { width: 25px; text-align: center; } td.next a { font-wegith: bold; } table.cal td { padding: 3px; } /* current date */ table.cal td.cdt { background: #f0f4fe; font-weight: bold; } /* current date is sunday */ table.cal td.scd { background: #E83903; color: #fff; } /* default days */ table.cal td.def { color: #5b6376; } /* sunday days */ table.cal td.sbg { color: #dc143c; background: #f7f7f7; } /* week defaults */ table.cal tr.week td { width: 20px; text-align: center; } /* week default sunday day */ table.cal td.wsd { background: #000064; color: #ffffff;} /* week default days */ table.cal td.wdd { background: #e0eaff; color: 4974d5; } /* week selected day */ table.cal td.wsl { background: #e0eaff; color: #000064;} table.cal td.wss { background: #ffa500; color: #ffffff;} </style> <body> <?php class Calendar { var $year; var $month; var $date; var $leap; var $lang; var $path; var $dates; function Calendar($l) { $this->year = date('Y'); $this->month = date('n'); $this->date = date('j'); $this->leap = date('L'); $this->lang = $l; $this->month_names = array( 'uz'=>array(1=>'Yanvar', 'Fevral', 'Mart', 'Aprel', 'May', 'Iyun', 'Iyul', 'August', 'Sentyabr', 'Oktyabr', 'Noyabr', 'Dekabr'), 'ru'=>array(1=>'Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'), 'en'=>array(1=>'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'Septempber', 'Oktober', 'November', 'December') ); $this->week_names = array( 'uz'=>array('Du', 'Se', 'Ch', 'Pa', 'Ju', 'Sh', 'Ya'), 'ru'=>array('Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'), 'en'=>array('Su', 'Mo', 'Tu', 'We', 'Tr', 'Fr', 'St') ); $this->dates = array(); } function Days(){ if($this->month==3 or $this->month==6 or $this->month==9 or $this->month==11){ return 30; }else if($this->month==2){ if($this->leap){ return 29; }else{ return 28; } }else{ return 31; } } function First(){ $first_day = date('w', mktime(0, 0, 0, $this->month, 1, $this->year)); if($this->lang=='uz' or $this->lang=='ru'){ $first_day = ($first_day==0) ? 6 : $first_day - 1; } return $first_day; } function Week(){ return date('w', mktime(0, 0, 0, $this->month, date('d'), $this->year)); } function Body() { $count_days = 0; $space_days = 0; $tbl = "<table cellspacing=0 cellpadding=0 border=0 class='cal'>"; $tbl.= "<tr>"; $tbl.= "<td colspan=7 align=center>"; $tbl.= "<table cellspacing=0 cellpadding=0 border=0 style='border-collapse:collapse'>"; $tbl.= "<tr>"; if(($this->month-1)==0){ $tbl.= "<td class='prev'><a href='".$this->path."y=".($this->year-1)."&m=12&d=".$this->date."'>«</a></td>"; }else{ $tbl.= "<td class='prev'><a href='".$this->path."y={$this->year}&m=".($this->month-1)."&d=".$this->date."&a=p'>«</a></td>"; } $tbl.= "<td class='center'>".$this->month_names[$this->lang][$this->month]." ".$this->year."</td>"; if(($this->month+1)==13){ $tbl.= "<td class='next'><a href='".$this->path."y=".($this->year+1)."&m=1&d=".$this->date."&a=n'>»</a></td>"; }else{ $tbl.= "<td class='next'><a href='".$this->path."y={$this->year}&m=".($this->month+1)."&d=".$this->date."'>»</a></td>"; } $tbl.= "</tr>"; $tbl.= "</table>"; $tbl.= "</td>"; $tbl.= "</tr>"; $tbl.= "<tr class='week'>"; for($col=0; $col<7; $col++){ $w = $this->Week(); $val = $this->week_names[$this->lang][$col]; if($this->lang=='uz' or $this->lang=='ru'){ if($w==0 && $col==6){ $tbl.= "<td class='wss'>{$val}</td>"; }else{ if($col==($w-1)){ $tbl.= "<td class='wsl'>{$val}</td>"; }else{ $cls = ($col==6) ? 'wsd' : 'wdd'; $tbl.= "<td class='$cls'>{$val}</td>"; } } }else{ if($col==$w){ $cls = ($col==0) ? 'wss' : 'wsl'; $tbl.= "<td class='{$cls}'>{$val}</td>"; }else{ $cls = ($col==0) ? 'wsd' : 'wdd'; $tbl.= "<td class='{$cls}'>{$val}</td>"; } } } $tbl.= "</tr>"; for($row=0; $row<6; $row++){ $tbl.= "<tr>"; for($col=0; $col<7; $col++){ if($space_days<$this->First()){ $tbl.= "<td> </td>"; }else{ $count_days++; if($count_days<=$this->Days()){ $en = ($this->lang=='en') ? 0 : 6; if($count_days==date('d')){ $cls = ($en==$col) ? 'scd' : 'cdt'; $tbl.= "<td class='{$cls}'>"; if($this->getDates($count_days)){ $m = $this->month; $d = $count_days; $tbl.= "<a href='".$this->path."y={$this->year}&m={$m}&d={$d}'><b>{$count_days}</b></a>"; }else{ $tbl.= $count_days; } $tbl.= "</td>"; }else{ $cls = ($en==$col) ? 'sbg' : 'def'; $tbl.= "<td class='{$cls}'>"; if($this->getDates($count_days)){ $m = $this->month; $d = $count_days; $tbl.= "<a href='".$this->path."y={$this->year}&m={$m}&d={$d}'><b>{$count_days}</b></a>"; }else{ $tbl.= $count_days; } $tbl.= "</td>"; } }else{ $tbl.= "<td> </td>"; } } $space_days++; } $tbl.= "</tr>"; } $tbl.= "</table>"; return $tbl; } function setAction() { if(!empty($_GET['y']) && !empty($_GET['m']) && !empty($_GET['d'])) { $y = (int) $_GET['y']; $m = (int) $_GET['m']; $d = (int) $_GET['d']; if(is_numeric($y) && is_numeric($m) && is_numeric($d)){ if($y>=2000 && $y<=2050){ $this->year = $y; } if($m<=12){ $this->month = $m; } if($d<=$this->Days()){ $this->date = $d; } } } } function getDates($d) { $result = 0; if(is_array($this->dates) && count($this->dates)>0){ foreach($this->dates as $k=>$v){ if(!preg_match("/^([0-9]{4})\-([0-9]{2})\-([0-9]{2})$/i", $v)){ die("Incorrect date: {$v}"); }else{ $m = ($this->month<10) ? '0'.$this->month : $this->month; $c = ($d<10) ? '0'.$d : $d; $y = $this->year; $l = trim($y.'-'.$m.'-'.$c); if(strcmp($v, $l)==0){ $result = 1; } } } } return $result; } } $cal = new Calendar('ru'); // ru | en $cal->setAction(); $cal->path = 'calendar.php?'; $cal->dates = array('2009-08-21'); print $cal->Body(); ?> </body> </html>
  7. Кто нибудь установил MCFileManager или MCImagerManager я попробуя у меня вообще не получаестя ... ? Fatal error: Trying to get out of defined root path. Root: Z:/home/192.168.1.4/www/editor/jscripts/tiny_mce/plugins/imagemanager/images, Path: Z:/home/192.168.1.4/www/editor/imagemanager/images in Z:\home\192.168.1.4\www\editor\jscripts\tiny_mce\plugins\imagemanager\classes\FileSystems\FileFactory.php on line 91 даёт такая ошибка
  8. SELECT cm_message from `chat_messages` order by `cm_id` desc limit 10
  9. Нашёл всё как это делать. Индексировать надо ...
  10. xaero

    LEFT JOIN LIMIT

    что то тут лишний?
  11. Привет всем!!! у меня есть триггер который удаляет из двух таблиц: DELIMITER # CREATE TRIGGER `otz_delete` BEFORE DELETE ON orders_status_otzvon FOR EACH ROW BEGIN /* delete from crm_telephony */ DELETE FROM crm_telephony WHERE id_zv=OLD.id_zv AND type='otzvon'; /* delete from crm_log */ DELETE FROM crm_log WHERE log_id=OLD.id_zv AND process=28; END;# Результат можно посмотреть здесь (это у меня локалке так работает 26 сек) : http://www.jetScreenshot.com/demo/20090608-78y-29kb.jpg
  12. xaero

    LEFT JOIN LIMIT

    У меня есть такой sql код: select sites.*, cats.cat_id as cat_id, scats.name as cat_name, aff.affiliate_firstname as affiliate_firstname, aff.affiliate_email_address as aff_mail, afs.view as view, afs.in_cart as in_cart, afs.orders as orders, afs.customers as customers, afs.date as date, afs.uniq_hosts_liv as uniq_hosts_liv, afs.uniq_hosts_ramb as uniq_hosts_ramb, afs.pages_liv as pages_liv, afs.pages_ramb as pages_ramb, afs.tic as tic, afs.pr as pr from affiliate_sites as sites left join affiliate_sites_to_category as cats on(sites.id=cats.affiliate_site) left join affiliate_sites_category as scats on(cats.cat_id=scats.id) left join affiliate_affiliate as aff on(sites.affiliate_id=aff.affiliate_id) left join affiliate_statistics as afs on(sites.id=afs.affiliate_site) left join affiliate_statistics as afs on(sites.id=afs.affiliate_site) в этой таблице очень много записав мне нужно только один запись примерно так: ORDER afs.date DESC LIMIT 0,1
  13. xaero

    триггеры

    Здравствуйте ... для не которых таблицы я сделал тригерры. Тригеррые запустил в MySQL front и MySQL HeidiSQL там работает все классно вот триггеры: DELIMITER $$ DROP TRIGGER IF EXISTS `cdr_update`$$ CREATE TRIGGER `cdr_update` AFTER UPDATE ON cdr FOR EACH ROW BEGIN /* update crm_telephony */ UPDATE crm_telephony SET id_zv = NEW.id_cd, orders_id = NEW.orders_id, man_id = NEW.man_id, type_zv = NEW.type_zv, telephone = NEW.telephone, date_start = NEW.calldate, duration = NEW.billsec, status = NEW.disposition, record = NEW.userfield, comment = NEW.comment, dest = NEW.dst WHERE id_zv=OLD.id_cd AND type='cdr'; /* update crm_log */ UPDATE crm_log SET log_id = NEW.id_cd, man_id = NEW.man_id, date_start = NEW.calldate, date_finish = DATE_ADD(NEW.calldate, INTERVAL NEW.duration SECOND), telephone = NEW.telephone, dest = NEW.dst, type = 29, type_zv = NEW.type_zv, action = 'view', comment = NEW.comment, process = 29, orders_id = NEW.orders_id WHERE log_id=OLD.id_cd AND process=29; END;$$ /* insert cdr table trigger */ DELIMITER $$ DROP TRIGGER IF EXISTS `cdr_insert`$$ CREATE TRIGGER `cdr_insert` AFTER INSERT ON cdr FOR EACH ROW BEGIN /* insert crm_telephony */ INSERT INTO crm_telephony SET id_zv = NEW.id_cd, orders_id = NEW.orders_id, man_id = NEW.man_id, type_zv = NEW.type_zv, type = 'cdr', telephone = NEW.telephone, date_start = NEW.calldate, duration = NEW.billsec, status = NEW.disposition, record = NEW.userfield, comment = NEW.comment, dest = NEW.dst; /* insert crm_log */ INSERT INTO crm_log SET log_id = NEW.id_cd, man_id = NEW.man_id, date_start = NEW.calldate, date_finish = DATE_ADD(NEW.calldate, INTERVAL NEW.duration SECOND), telephone = NEW.telephone, dest = NEW.dst, type = 29, type_zv = NEW.type_zv, action = 'view', comment = NEW.comment, process = 29, orders_id = NEW.orders_id; END;$$ но когда запускаю в phpMyAdmin даёт ошибка ...? можно ли в phpmyadmin запускать не сколько триггеров сразу ... ? спасибо за ответы ...
  14. http://fanat.uz обсуждайте работу
  15. возникла ещё один проблема а можно ли использовать триггеры два разных таблиц например у меня есть таблица - А для Б(таблиц) и В(таблиц) - я хотел использовать тригееры инсерт но там появляется такая ошибка: /* SQL Error: This version of MySQL doesn't yet support 'multiple triggers with the same action time and event for one table' */
  16. trigger - разрешено спасибо за ответы ..... очень благодарен
  17. так пробовал но c пейджингом беда: (SELECT id_zv as id_zv, orders_id as orders_id, type_zv as type_zv, man_id as man_id, telephone as telephone, date_start as date_start, last_mod as last_mod, prodolwit as prodolwit, is_ok as is_ok, local_hour as local_hour, count as count, record as record, comment as comment, 'phone' as type, '' as dest FROM orders_status_otzvon WHERE ( `type_zv` = 'sip_not_answered' OR `man_id` = 100 ) AND (`is_ok` = 0 AND `orders_id` = 1785 AND `date_start` >= '2009-06-06 12:00:33' AND date_start<='2009-07-09 12:00:12 23:59:00' AND `telephone` = 'TEST' ) ORDER BY date_start DESC LIMIT 0, 20) UNION (SELECT id_cd as id_zv, orders_id as orders_id, type_zv as type_zv, man_id as man_id, telephone as telephone, calldate as calldate, '' as last_mod, billsec as prodolwit, disposition as is_ok, '' as local_hour, '' as count, userfield as record, comment as comment, 'cdr' as type, dst as dest FROM cdr WHERE ( `type_zv` = 'sip_not_answered' OR `man_id` = 100 ) AND (disposition='NO ANSWER' AND `orders_id` = 1785 AND `calldate` >= '2009-06-06 12:00:33' AND calldate<='2009-07-09 12:00:12 23:59:00' AND `telephone` = 'TEST' ) ORDER BY calldate DESC LIMIT 0, 20) ORDER BY date_start DESC LIMIT 0, 20
  18. там 200 000 записей
  19. Вот у меня есть такой SQL: (SELECT `id_zv` AS `id_zv`, `orders_id` AS `orders_id`, `type_zv` AS `type_zv`, `man_id` AS `man_id`, `telephone` AS `telephone`, `date_start` AS `date_start`, `last_mod` AS `last_mod`, `prodolwit` AS `prodolwit`, `is_ok` AS `is_ok`, `local_hour` AS `local_hour`, `count` AS `count`, `record` AS `record`, `COMMENT` AS `COMMENT` , 'phone' AS `TYPE` , '' AS `dest` FROM orders_status_otzvon WHERE 0 =0 ) UNION ( SELECT `id_cd` AS `id_zv`, `orders_id` AS `orders_id`, `type_zv` AS `type_zv`, `man_id` AS `man_id`, `telephone` AS `telephone`, `calldate` AS `date_start`, '' AS `last_mod`, `billsec` AS `prodolwit`, `disposition` AS `is_ok`, '' AS `local_hour`, '' AS `count`, `userfield` AS `record`, `COMMENT` AS `COMMENT` , 'cdr' AS `TYPE` , `dst` AS `dest` FROM cdr WHERE 0 =0) ORDER BY `date_start` DESC LIMIT 0 , 25 у меня локалке работает 0.078 - а сервере 10 сек (долго) ... кто нибудь знает как ускорить процесс ?
  20. xaero

    create view

    Вот у меня есть такой query и я созадю view чтобы было удобно работать с условиями иначе каждому отдельный условия написать надо всё работает но с скоростью беда !!!! ест ли какой нибуд способ чтобы он работал быстро create or replace view log_tables as (select cd.id_cd as id, cd.man_id as man_id, concat(man.username, ' ',man.lastname) as actor_name, cd.calldate as date_start, DATE_ADD(cd.calldate, INTERVAL cd.duration SECOND) as date_finish, 29 as type, 'view' as action, cd.comment as comment from cdr as cd left join managers as man on (cd.man_id = man.man_id) ) union (select otz.id_zv as id, otz.man_id as man_id, concat(man.username, ' ',man.lastname) as actor_name, otz.date_start as date_start, DATE_ADD(otz.date_start, INTERVAL otz.prodolwit SECOND) as date_finish, 28 as type, 'view' as action, otz.comment as comment from orders_status_otzvon as otz left join managers as man on (otz.man_id = man.man_id) ) union (select ohs.id as id, ohs.manager_id as man_id, concat(man.username, ' ',man.lastname) as actor_name, ohs.date_open as date_start, ohs.date_finish as date_finish, 3 as type, 'view' as action, ohs.comments as comment from orders_status_history_work as ohs left join managers as man on (ohs.manager_id = man.man_id) ) union (select log.id as id, log.actor_id as man_id, concat(man.username, ' ',man.lastname) as actor_name, log.date as date_start, now() as date_finish, 0 as type, 'view' as action, log.text as comment from log left join managers as man on (log.actor_id = man.man_id) )
  21. я тоже понял ... где тут ответ array_unique он убирает повторяющихся значении а мне нужен идентификаторы
  22. вот массив: а можно по нему сделать рекурсивную функцию который ищет паренты (37, 28, 29) по опеределённым идентификаторм (id) $array = array( array('id'=>1, 'type'=>38), array('id'=>2, 'type'=>38), array('id'=>3, 'type'=>38), array('id'=>4, 'type'=>38), array('id'=>5, 'type'=>37), array('id'=>6, 'type'=>38), array('id'=>7, 'type'=>38), array('id'=>8, 'type'=>37), array('id'=>9, 'type'=>38), array('id'=>10, 'type'=>38), array('id'=>11, 'type'=>38), array('id'=>12, 'type'=>38), array('id'=>13, 'type'=>38), array('id'=>14, 'type'=>29), array('id'=>15, 'type'=>38), array('id'=>16, 'type'=>38), array('id'=>17, 'type'=>38), array('id'=>18, 'type'=>38), array('id'=>19, 'type'=>27), array('id'=>20, 'type'=>38), array('id'=>21, 'type'=>38), array('id'=>22, 'type'=>38), array('id'=>23, 'type'=>38) );
  23. здравствуйте дорогие программисты мне нужно один вещь ecть такой массив надо группировать его ... $array = array( type_id=>38, type_id=>38, type_id=>38, type_id=>38, type_id=>37, type_id=>38, type_id=>38, type_id=>38, type_id=>29, type_id=>38, type_id=>38, type_id=>38, type_id=>27, type_id=>38, type_id=>38, type_id=>38, type_id=>38, type_id=>38, type_id=>38 ); как группировать если перед 38 нет не какой число который не равно на 38 значить он без типа, если после 37 там идет 38 надо группировать его 37=>array(все 38) до следующего 27 или 28 итого выводим вот такой результат Без типа: type_id=>38, type_id=>38, type_id=>38, type_id=>38, Тип с 37: type_id=>38, type_id=>38, type_id=>38, type_id=>29, type_id=>38, type_id=>38, type_id=>38, Тип с 28: type_id=>38, type_id=>38, type_id=>38, type_id=>38, type_id=>38, type_id=>38 Как можно реализовать такую структуру? Спасибо за внимание....
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy