久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <legend id='i90V6'><style id='i90V6'><dir id='i90V6'><q id='i90V6'></q></dir></style></legend>
    • <bdo id='i90V6'></bdo><ul id='i90V6'></ul>

    <small id='i90V6'></small><noframes id='i90V6'>

    <tfoot id='i90V6'></tfoot>

    1. <i id='i90V6'><tr id='i90V6'><dt id='i90V6'><q id='i90V6'><span id='i90V6'><b id='i90V6'><form id='i90V6'><ins id='i90V6'></ins><ul id='i90V6'></ul><sub id='i90V6'></sub></form><legend id='i90V6'></legend><bdo id='i90V6'><pre id='i90V6'><center id='i90V6'></center></pre></bdo></b><th id='i90V6'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='i90V6'><tfoot id='i90V6'></tfoot><dl id='i90V6'><fieldset id='i90V6'></fieldset></dl></div>

      1. 來自數據庫的系譜/家譜圖

        Pedigree/Family tree chart from database(來自數據庫的系譜/家譜圖)

        <legend id='GPbMY'><style id='GPbMY'><dir id='GPbMY'><q id='GPbMY'></q></dir></style></legend>
          <tbody id='GPbMY'></tbody>

        <small id='GPbMY'></small><noframes id='GPbMY'>

          • <i id='GPbMY'><tr id='GPbMY'><dt id='GPbMY'><q id='GPbMY'><span id='GPbMY'><b id='GPbMY'><form id='GPbMY'><ins id='GPbMY'></ins><ul id='GPbMY'></ul><sub id='GPbMY'></sub></form><legend id='GPbMY'></legend><bdo id='GPbMY'><pre id='GPbMY'><center id='GPbMY'></center></pre></bdo></b><th id='GPbMY'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='GPbMY'><tfoot id='GPbMY'></tfoot><dl id='GPbMY'><fieldset id='GPbMY'></fieldset></dl></div>
            <tfoot id='GPbMY'></tfoot>

                  <bdo id='GPbMY'></bdo><ul id='GPbMY'></ul>

                • 本文介紹了來自數據庫的系譜/家譜圖的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試從數據庫生成譜系(換句話說,家譜:))表...

                  I am trying to generate pedigree (in other words family tree :) ) table from database...

                  我的架構:

                  CREATE TABLE `horses` ( 
                  `horse_id` int(10) NOT NULL AUTO_INCREMENT,
                  `horse_name` varchar(32) NOT NULL,
                  `horse_sire` int(10) DEFAULT NULL,
                  `horse_dam` int(10) DEFAULT NULL, 
                  PRIMARY KEY (`horse_id`),
                  KEY `FKsire` (`horse_sire`),
                  KEY `FKdam` (`horse_dam`),
                  CONSTRAINT `FKdam` FOREIGN KEY (`horse_dam`) REFERENCES `horses` (`horse_id`),
                  CONSTRAINT `FKsire` FOREIGN KEY (`horse_sire`) REFERENCES `horses` (`horse_id`)
                  )
                  

                  附言'horse_dam' 和 'horse_sire' 代表父母......我在這個問題上花了幾天時間,搜索,試驗......目前我有這個部分解決方案:

                  p.s. 'horse_dam' and 'horse_sire' represents parents... I have spent days on this problem, searching, experimenting... And currently I have this partly solution:

                  display_children($selected_horse_id, 5);
                  
                          function display_children($parent, $level) {
                              mysql_connect('localhost','root','');
                              mysql_select_db('hdb');
                              $result = mysql_query('SELECT * FROM horses WHERE horse_id="'.$parent.'";');
                  
                  
                              while ($row = mysql_fetch_array($result)) {
                  
                                  echo "<tr><td>";
                                  echo $row['horse_name'];
                                  echo "</td></tr>";
                  
                                  display_children($row['horse_dam'], $level+1);
                                  display_children($row['horse_sire'],$level+1);
                              }
                          }
                  

                  在一行中生成表:(我想不出正確的方法來實現它......我想要的結果是 譜系查詢

                  which generates table in one row :( I cannot think of proper way to implement it... And the result I want is Pedigree Query

                  非常感謝任何幫助或提示:),提前致謝

                  Any help or hint is highly appreciated :), Thanks in advance

                  推薦答案

                  我幾個月前已經解決了問題...我正在發布答案,所以這可能對其他開發人員有所幫助...附言該項目是用 Yii 1.1 編寫的

                  I have already resolved problem few month ago... I'm posting answer, so this might be helpful for other fellow developers... p.s. The project was written in Yii 1.1

                  首先,在我的 HorseController 中分配了私有數組類型變量,我將在其中保留譜系:

                  Firstly, in my HorseController assigned private array type variable where I am going to keep Pedigree:

                  private $horses = array();
                  

                  然后,我編寫了從數據庫中獲取所有節點(父節點)的函數:

                  Then, I wrote function that will get all nodes (parents) from database:

                  public function getParents($id)
                  {
                      global $horses;
                      $horses[] = Horses::model()->findByPk($id)->horse_id;
                      if($this->loadModel($id)->horse_sire != null && $this->loadModel($id)->horse_dam != null)
                      {
                          $this->getParents($this->loadModel($id)->horse_sire);
                          $this->getParents($this->loadModel($id)->horse_dam);
                      }
                      return $horses;
                  }
                  

                  然后,我修改了 ActionView 函數,其中數據庫中的所有節點都將傳遞給 View

                  Then, I modified ActionView function, where all nodes from database will be passed to View

                  public function actionView($id)
                  {
                      $this->horses = $this->getParents($id);
                      $this->render('view',array(
                          'model'=>$this->loadModel($id),
                          'parents'=>$this->horses,
                      ));
                  }
                  

                  最后是一些顯示系譜的丑陋代碼(例如系譜查詢):)

                  And finally a bit of UGLY CODE that will show pedigree (like this Pedigree Query) :)

                  <table>
                              <?php
                                  $reverse_multiplier = (count($parents)+1)/2;
                                  $last_node_count = 0;
                                  for($i = 0; $i < count($parents); $i++)
                                  {
                                      if($i == 0 && $last_node_count ==1)
                                          echo "<tr>";
                  
                                      echo "<td rowspan='$reverse_multiplier'>";
                  
                                      echo "<a href=".Yii::app()->baseUrl."/index.php/horses/".Horses::model()->model()->findByPk($parents[$i])->horse_id." >";
                                      echo Horses::model()->model()->findByPk($parents[$i])->horse_name;
                                      echo "</a>";
                                      echo "<br/>";
                                      echo Horses::model()->model()->findByPk($parents[$i])->horse_yob;
                  
                                      echo "</td>";
                                      if($reverse_multiplier == 1 || $reverse_multiplier == 0.5)
                                          echo "</tr>";
                  
                                      if($reverse_multiplier == 0.5 && $last_node_count <= (count($parents)+1)/4)
                                          $reverse_multiplier = (count($parents)+1)/8;
                                      else
                                          $reverse_multiplier = $reverse_multiplier/2;
                  
                                      if($last_node_count == (count($parents)+1)/4)
                                      {
                                          $reverse_multiplier = (count($parents)+1)/4;
                                          $last_node_count=0;
                                      }
                                      if($reverse_multiplier == 0.5 || $reverse_multiplier == 1)
                                          $last_node_count++;
                                  }
                              ?>
                          </table>
                  

                  就是這樣:)希望它有幫助...

                  And that's it :) Hope it was helpful...

                  這篇關于來自數據庫的系譜/家譜圖的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
                  <i id='MRUg2'><tr id='MRUg2'><dt id='MRUg2'><q id='MRUg2'><span id='MRUg2'><b id='MRUg2'><form id='MRUg2'><ins id='MRUg2'></ins><ul id='MRUg2'></ul><sub id='MRUg2'></sub></form><legend id='MRUg2'></legend><bdo id='MRUg2'><pre id='MRUg2'><center id='MRUg2'></center></pre></bdo></b><th id='MRUg2'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='MRUg2'><tfoot id='MRUg2'></tfoot><dl id='MRUg2'><fieldset id='MRUg2'></fieldset></dl></div>

                        • <bdo id='MRUg2'></bdo><ul id='MRUg2'></ul>

                          <tfoot id='MRUg2'></tfoot>
                          <legend id='MRUg2'><style id='MRUg2'><dir id='MRUg2'><q id='MRUg2'></q></dir></style></legend>

                          <small id='MRUg2'></small><noframes id='MRUg2'>

                            <tbody id='MRUg2'></tbody>
                            主站蜘蛛池模板: 国产免费一区二区三区 | 国产超碰人人爽人人做人人爱 | 日屁视频| h片在线看| 国产欧美一区二区三区在线看蜜臀 | 精品久久久网站 | 奇米久久久 | 国产日韩中文字幕 | 国产精品自产拍 | 6080亚洲精品一区二区 | 91网视频 | 放个毛片看看 | 久久久久久久久中文字幕 | 成人福利在线 | 91综合网 | av在线天堂 | 毛片综合 | 久久久久久中文字幕 | 亚洲精品成人免费 | 一本一道久久a久久精品蜜桃 | 国产美女视频一区 | 久热精品免费 | 女人夜夜春 | 99久久99| 亚洲视频一 | 亚洲视频在线观看免费 | 精品96久久久久久中文字幕无 | 久久精品国产a三级三级三级 | 日韩在线视频网址 | 日韩成人在线观看 | 久久久精品久久 | 国产精品色 | 一区二区三区观看视频 | 美女视频三区 | 国产一区二区高清在线 | 久久大香| 免费观看www7722午夜电影 | 亚洲精品久久久久久久久久久久久 | 欧美一级久久久猛烈a大片 日韩av免费在线观看 | 欧美一级片 | 国产一区在线视频 |