OSDN Git Service

MERGE: データベースハンドラーを再設計したnewdbhandler-masterブランチをmasterにマージ。
authorsakamocchi <o-takashi@sakamocchi.jp>
Tue, 1 May 2012 11:41:19 +0000 (20:41 +0900)
committersakamocchi <o-takashi@sakamocchi.jp>
Tue, 1 May 2012 11:41:19 +0000 (20:41 +0900)
詳細は以下を参照のこと

[4.0の開発 - 19] データベースハンドラーの再設計
http://japan.nucleuscms.org/bb/viewtopic.php?p=27997

1  2 
nucleus/libs/SKIN.php
nucleus/upgrades/upgrade1.5.php

@@@ -392,16 -387,11 +387,11 @@@ class Ski
         */
        public function getContentFromDB($skintype)
        {
 -              $query = "SELECT scontent FROM %s WHERE sdesc=%d and stype=%s;";
 +              $query = "SELECT scontent FROM %s WHERE sdesc=%d and stype='%s';";
-               $query = sprintf($query, sql_table('skin'), (integer) $this->id, sql_real_escape_string($skintype));
-               $res = sql_query($query);
-               
-               if ( sql_num_rows($res) == 0 )
-               {
-                       return FALSE;
-               }
+               $query = sprintf($query, sql_table('skin'), (integer) $this->id, DB::quoteValue($skintype));
+               $res = DB::getValue($query);
                
-               return sql_result($res, 0, 0);
+               return $res ? $res : '';
        }
        
        /**
@@@ -90,13 -90,12 +90,14 @@@ function upgrade_do150() 
        }
        
        // in templates: add 'comments'-templatevar to all non-empty ITEM templates     
-       $res = sql_query('SELECT * FROM '.sql_table('template').' WHERE tpartname=\'ITEM\'');
-       while ($o = mysql_fetch_object($res)) {
-               if ( i18n::strpos($o->tcontent,'<%comments%>') === FALSE)
+       $res = DB::getResult('SELECT * FROM '.sql_table('template').' WHERE tpartname=\'ITEM\'');
 -      foreach ( $res as $row ) {
 -      if ( i18n::strpos($o->tcontent,'<%comments%>') === FALSE ) {
 -      $newval = $row['tcontent'] . '<%comments%>';
++      foreach ( $res as $row )
++      {
++              if ( i18n::strpos($o->tcontent,'<%comments%>') === FALSE )
 +              {
-                       $newval = $o->tcontent . '<%comments%>';
-                       $query = 'UPDATE '.sql_table('template').' SET tcontent=\''. addslashes($newval).'\' WHERE tdesc=' . $o->tdesc . ' AND tpartname=\'ITEM\'';
-                       upgrade_query('Updating ITEM part in template ' . $o->tdesc, $query);
++                      $newval = $row['tcontent'] . '<%comments%>';
+                       $query = 'UPDATE '.sql_table('template').' SET tcontent=\''. addslashes($newval).'\' WHERE tdesc=' . $row['tdesc'] . ' AND tpartname=\'ITEM\'';
+                       upgrade_query('Updating ITEM part in template ' . $row['tdesc'], $query);
                }
        }