<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    if($queryResult=mysql_query($str,$this->conn))
                {
                    
    $resultTable = new DbTable();
                    
    $fields = array();
                    
    $rows = array();
                    
    while ($property = mysql_fetch_field($queryResult))
                    {
                        
    $fields[] = array($property->name,$property->type);
                    }
                    
    while ($row = mysql_fetch_array($queryResult,MYSQL_NUM)) {
                        
    foreach($row as $k=>$v)
                        
    if(is_numeric($v))
                        
    $row[$k]=floatval($v);
                        
    $rows[] = $row;
                    }
                    
    $resultTable->fields = $fields;
                    
    $resultTable->rows = $rows;
                }

    class DbTable
    {
        
    var $rows;
        
    var $fields;
        
    var $tableName;

        
    /**
         * {
         *     objectType:"DbTable",
         *  tableName:"tableName",
         *     fields:[
         *         [col1Name,col1Type],
         *         [col2Name,col2Tpye],
         *         [col3Name,col3Type]],
         *     rows:[
         *         [row1Col1,row1Col2,row1Col3],
         *         [row2Col1,row2Col2,row2Col3],
         *         [row3Col1,row3Col2,row3Col3]]
         * }
         
    */
        
    function toString()
        {
            
    $jsonFields = json_encode($this->fields);
            
    $josnRows = json_encode($this->rows);
            
    $result = "{objectType:\"DbTable\",tableName:".$this->tableName.",fields:".$jsonFields.",rows:".$josnRows."}";
            
    return $result;
        }
    }

    class DataSet
    {
        
    var $tables;

        
    /**
         * {
         *     objectType:"DataSet",
         *     tables:[
         *             {
         *                objectType:"DbTable",
         *                 tableName:"table1Name",
         *                 fields:[
         *                     [col1Name,col1Type],
         *                     [col2Name,col2Tpye],
         *                     [col3Name,col3Type]],
         *                 rows:[
         *                     [row1Col1,row1Col2,row1Col3],
         *                     [row2Col1,row2Col2,row2Col3],
         *                     [row3Col1,row3Col2,row3Col3]]
         *           },
         *           {
         *               objectType:"DbTable",
         *                 tableName:"table2Name",
         *                 fields:[
         *                     [col1Name,col1Type],
         *                     [col2Name,col2Tpye],
         *                     [col3Name,col3Type]],
         *                 rows:[
         *                     [row1Col1,row1Col2,row1Col3],
         *                     [row2Col1,row2Col2,row2Col3],
         *                     [row3Col1,row3Col2,row3Col3]]
         *             }
         *            ]
         * }
         
    */
        
    /**
         * $resultDataSet = new DataSet();
         * $tables[] = DbTable1->toString();
         * $tables[] = DbTable2->toString();
         * $resultDataSet->tables = $tables;
         * $resultDataSet->toString();
         
    */
        
    function toString()
        {
            
    $result = "{objectType:\"DataSet\",tables:[";
            
    foreach($this->tables as $k=>$v)
            {
                
    $result.= "{".$this->tables[$k]."},";
            }
            
    $result = substr($result,0,-1);
            
    $result.="]}";
            
    echo $result;
        }
    }

        /**
         * insert into tableName (col1,col2,col3) values ('v1','v2','v3')
         * jsonStr:
         * {
         *         "rows" : [col1,col2,col3]
         * }
         * @param $jsonStr
         * @param $tableName
         
    */
        
    function rowInsert($jsonStr,$tableName){
            
    $jsonDecode = json_decode($jsonStr);
            
    $result     = "insert into ".$tableName." values(";
            
    foreach($jsonDecode ->rows as $k => $v){
                
    $result .= "'".$v."',";
            }
            
    $result  = substr($result,0,-1);
            
    $result .= ")";
            
    return $result;
        }

        
    /**
         * UPDATE tableName SET col1 = col1Value, col2 = col2Value WHERE 1=1 AND primaryKey = key
         * @param $jsonStr
         * @param $tableName
         
    */
        
    function rowUpdate($jsonStr,$tableName)
        {
            
    $jsonDecode = json_decode($jsonStr);
            
    $sql        = 'DESCRIBE `'.$tableName.'`;';
            
    $descRs     = mysql_query($sql);
            
    $setStr     = "UPDATE ".$tableName." SET";
            
    $whereStr   = "  WHERE true ";
            
    $i          = 0;
            
    while ($row = mysql_fetch_array($descRs,MYSQL_NUM)) {
                
    if($row[3== "PRI")
                
    $whereStr.=" AND ".$row[0]." = '".$jsonDecode->rows[$i]."";
                
    $setStr.= " ".$row[0]." = '".$jsonDecode->rows[$i]."',";
                
    $i++;
            }
            
    $setStr = substr($setStr,0,-1);
            
    return $setStr.$whereStr;
        }

        
    /**
         * DELETE tableName WHERE 1=1 AND primaryKey = key
         * @param $jsonStr
         * @param $tableName
         
    */
        
    function rowDelete($jsonStr,$tableName)
        {
         
    $jsonDecode = json_decode($jsonStr);
         
    $sql        = 'DESCRIBE `'.$tableName.'`;';
         
    $descRs     = mysql_query($sql);
         
    $result     = " DELETE ".$tableName." WHERE true ";
         
    while ($row = mysql_fetch_array($descRs,MYSQL_NUM)) {
             
    $i=0;
             
    if($row[3== "PRI")
             
    $result.=" AND ".$row[0]." = '".$jsonDecode->rows[$i]."";
             
    $i++;
         }
         
    return $result;
        }




































    posted on 2010-08-24 10:19 Ying-er 閱讀(708) 評論(0)  編輯  收藏 所屬分類: PHP
    主站蜘蛛池模板: 日本免费一区二区三区| 中文字幕亚洲无线码a| 免费少妇a级毛片人成网| 亚洲精品乱码久久久久久中文字幕| 亚洲Av综合色区无码专区桃色| 亚洲午夜久久久久久尤物| 日本黄页网址在线看免费不卡| 拍拍拍无挡免费视频网站| 在线观看91精品国产不卡免费| 亚洲精品成人网站在线观看| 亚洲熟妇无码一区二区三区导航 | 欧美激情综合亚洲一二区| a级片免费在线播放| 国产免费怕怕免费视频观看| 午夜影视日本亚洲欧洲精品一区| 亚洲精品无码mⅴ在线观看| 日本视频免费高清一本18| 亚洲高清偷拍一区二区三区| 亚洲成人午夜电影| 国产免费爽爽视频在线观看| 亚洲日韩VA无码中文字幕| 亚洲精品精华液一区二区| 国产成人精品免费午夜app| 亚洲av日韩av无码黑人| 国产成人免费AV在线播放 | jizz免费观看| 国产成人亚洲综合无码| 亚洲日韩在线观看免费视频| 亚洲国产精品视频| fc2成年免费共享视频网站| 永久亚洲成a人片777777| 免费日本一区二区| 亚洲国产精品久久人人爱| 很黄很色很刺激的视频免费| 亚洲欧洲另类春色校园网站| 67194熟妇在线永久免费观看| 亚洲综合激情另类小说区| 国产va精品免费观看| 精品国产亚洲AV麻豆 | 亚洲色偷拍区另类无码专区| xvideos永久免费入口|