<?php
	 
	exit;
	//require_once('inc/conn.php');
	require_once('inc/constant.php');
	require_once('inc/ls_syscode.php');
	//for($j=1;$j<=2;$j++)

 /*
			include('inc/conn.php');
			
			$opendb=new mydb();
			include('inc/char_set.php');


		$i=0;
		
				$tableResult = $opendb->query("show tables"); // mysqli_query
				while   ($row   =   mysqli_fetch_row($tableResult)) {   //删除多个ls_site_b2b表
					if(substr($row[0],0,11)=='ls_site_b2b'){
						
					//	$del_sql="ALTER TABLE ".$row[0]."  MODIFY COLUMN    `siteName` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL  "; ALTER TABLE `".$row[0]."` CHANGE `right` `right1` INT( 2 ) NOT NULL COMMENT '权重'
					// ALTER TABLE `ls_site_b2b` CHANGE `message` `message` VARCHAR( 256 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL 
					//	$del_sql=" ALTER TABLE `".$row[0]."` CHANGE `right` `right1` INT( 2 ) NOT NULL COMMENT '权重' ";
					// $del_sql=" ALTER TABLE `".$row[0]."`  CHANGE `message` `message` VARCHAR( 256 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL  ";  ALTER TABLE  `ls_seoitems_init` ADD  `seoBrief` TEXT NOT NULL COMMENT  '客户优化显示' AFTER  `alert`
					$del_sql="ALTER TABLE `".$row[0]."` ADD  `help` TEXT NOT NULL COMMENT  '帮助' AFTER  `memo` ";
					
					
						$del_query=$opendb->query($del_sql);
						echo $row[0]."ok,<br/>   ";
						$i++;
					}
					
				}
	
		//$tableResult   =   mysqli_list_tables($dbname); 
		echo "<br/>完成： $i  张表 ";
 
 */
 
 
 			include('inc/conn.php');
			
			$opendb=new mydb();
			include('inc/char_set.php');
			$i=0;
			$j=0;
			$addfield="seoBrief";
		
				$table  ="ls_products"; 
				$sqlbk= "CREATE TABLE ".$table."bak SELECT * FROM ". $table."";
				$tableResult =   $opendb->query($sqlbk); 
				if($tableResult) echo "backup ".$table."bak<br/> <br/>";
				
				$sql= "select * from " .$table. " where 1  " ;
				//echo $sql;
				$tableResult =   $opendb->query($opendb->conn,$sql); //?
				$select_rows2=mysqli_num_rows($tableResult); //总产品数
				// echo $select_rows2 ;

				//while   ($row   =   mysqli_fetch_row($tableResult)) {   //删除多个ls_site_b2b表
				while   ($row   =   mysqli_fetch_assoc($tableResult)) { 
				
					// if(substr($row[0],0,11)=='ls_seoitems'){
							  
						  //	$del_sql="ALTER TABLE ".$row[0]."  MODIFY COLUMN    `siteName` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL  "; ALTER TABLE `".$row[0]."` CHANGE `right` `right1` INT( 2 ) NOT NULL COMMENT '权重'
						  // ALTER TABLE `ls_site_b2b` CHANGE `message` `message` VARCHAR( 256 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL 
						  //	$del_sql=" ALTER TABLE `".$row[0]."` CHANGE `right` `right1` INT( 2 ) NOT NULL COMMENT '权重' ";
						  // $del_sql=" ALTER TABLE `".$row[0]."`  CHANGE `message` `message` VARCHAR( 256 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL  ";  ALTER TABLE  `ls_seoitems_init` ADD  `seoBrief` TEXT NOT NULL COMMENT  '客户优化显示' AFTER  `alert`
						 // $rescolumns="SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT  FROM    INFORMATION_SCHEMA.COLUMNS    WHERE       table_name = '".$row[0]."' AND table_schema = 'ls_submitcn'      and  COLUMN_NAME  =  '".$addfield."'";
						 // $rescolumnsResult = mysqli_query($opendb->conn,$rescolumns); //error 
						//  $allrows=mysqli_num_rows($rescolumnsResult);
						$newproductSpecification=$row['productSpecification'];
						//echo $newproductSpecification;
						   if($newproductSpecification !='')
					   {
							//  $changesql=" ALTER TABLE  `".$row[0]."` ADD  `".$addfield."` TEXT NOT NULL AFTER  `ID`";
							//$newproductSpecification=htmlspecialchars(strip_tags(htmlspecialchars_decode($row['productSpecification'],ENT_QUOTES)), ENT_QUOTES);
							$newproductSpecification= strip_tags(htmlspecialchars_decode($newproductSpecification,ENT_QUOTES)) ;
							$changesql=" update ".$table." set productSpecification='".$newproductSpecification."' where ID =".$row['ID']." ";
							   $changeResult = mysqli_query($opendb->conn,$changesql); 
							  // echo $row[0]." ok<br/>";
							  echo $row['ID']." ok<br/>";
							echo $newproductSpecification ."<br/><br/><br/>";
							   $j++;
						  }
							
 					//}

					//	$i++;
				 
					
				}
	
		//$tableResult   =   mysqli_list_tables($dbname); 
		// echo "<br/>完成： $j  张表 ";
		echo "<br/>finish: $j rows";

	?>
