Starting from: http://www.zzzzy.com/201406053158.html
1 /**2 * MySQL table field One-click Generate SQL to create SQLite3 * $DB Database4 * $tbname table name5 * $is _blob need to save the image binary array ("IMG1", "Img2", "img3") Form, default to False6 * $retbname custom generated SQLite table name7 * Statement form for return SQL8 */9 Ten Public functionCreat_sqlite ($db,$tbname,$is _blob=false,$retbname=false){ One A $runsql 1=$db->query ("Select * from"$tbname' Limit 1 '); - $fields _rows=$runsql 1-ColumnCount (); - the $TB _fields_info=Array(); - $TB _string= ""; - $dot= ""; - + for($i= 0;$i<$fields _rows;$i++) { - if($i= = 1) { + $dot= ", "; A } at - $TB _meta=$runsql 1->getcolumnmeta ($i); - $TB _string.=$dot.$TB _meta[' Name ']; - //var_dump ($TB _meta); - - //If there is data and the field exists in a field that needs to be canceled in if($is _blob&&In_array($TB _meta[' Name '],$is _blob)) { - $TB _string.= " "." Blob; to}Else { + //If you do not need to save as a binary - Switch($TB _meta[' Native_type ']){ the Case"Var_string": * $TB _string.= " "." varchar; $ Break;Panax Notoginseng - Case"LONG": the $TB _string.= " "." Integer; + Break; A the Case"BLOB": + $TB _string.= " "." Text; - Break; $ Case"TINY": $ $TB _string.= " "." smallint; - Break; - } the } - Wuyi if(isset($TB _meta[' Flags '] [1]) && ($TB _meta[' Flags '] [1] = = = "Primary_key")) { the $TB _string.= " "." PRIMARY KEY "; - } Wu - if(isset($TB _meta[' Flags '] [0]) && ($TB _meta[' Flags '] [0] = = = "Not_null")) { About $TB _string.= " "." Not NULL "; $ } - - //var_dump ($TB _meta); - } A + //the generated SQLite table name the $retbname=$retbname==true?$retbname:$tbname; - $ //SQL statement to create data the $creat _data= "CREATE TABLE IF not EXISTS {$retbname} ($TB _string);"; the the return $creat _data; the}
http://www.bkjia.com/PHPjc/780020.html www.bkjia.com true http://www.bkjia.com/PHPjc/780020.html techarticle starting from: http://www.zzzzy.com/201406053158.html 1/* * 2 * mysql table field one-key generation create SQLite SQL 3 * $DB database 4 * $tbname table name 5 * $is _blob Need to save the picture in binary ...