⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 acp_database.php

📁 这些都是我以前学习是用到的源码
💻 PHP
📖 第 1 页 / 共 4 页
字号:
													AND d.adnum = " . strval($i + 1);											$result2 = $db->sql_query($sql);											if ($row = $db->sql_fetchrow($result2))											{												// Determine if we must reset the sequences												if (strpos($row['rowdefault'], "nextval('") === 0)												{													$seq .= "SELECT SETVAL('{$table_name}_seq',(select case when max({$ary_name[$i]})>0 then max({$ary_name[$i]})+1 else 1 end FROM {$table_name}));\n";												}											}										}										while ($row = $db->sql_fetchrow($result))										{											$schema_vals = $schema_fields = array();											// Build the SQL statement to recreate the data.											for ($i = 0; $i < $i_num_fields; $i++)											{												$str_val = $row[$ary_name[$i]];												if (preg_match('#char|text|bool|bytea#i', $ary_type[$i]))												{													$str_quote = "'";													$str_empty = '';													$str_val = addslashes($str_val);												}												else if (preg_match('#date|timestamp#i', $ary_type[$i]))												{													if (empty($str_val))													{														$str_quote = '';													}													else													{														$str_quote = "'";													}												}												else												{													$str_quote = '';													$str_empty = 'NULL';												}												if (empty($str_val) && $str_val !== '0')												{													$str_val = $str_empty;												}												$schema_vals[$i] = $str_quote . $str_val . $str_quote;												$schema_fields[$i] = $ary_name[$i];											}											// Take the ordered fields and their associated data and build it											// into a valid sql statement to recreate that field in the data.											$sql_data .= "INSERT INTO $table_name (" . implode(', ', $schema_fields) . ') VALUES (' . implode(', ', $schema_vals) . ");\n";											if ($store == true)											{												$write($fp, $sql_data);											}											if ($download == true)											{												if (!empty($oper))												{													echo $oper($sql_data);												}												else												{													echo $sql_data;												}											}											$sql_data = '';										}										$db->sql_freeresult($result);										// Write out the sequence statements										if ($store == true)										{											$write($fp, $seq);										}										if ($download == true)										{											if (!empty($oper))											{												echo $oper($seq);											}											else											{												echo $seq;											}										}										$seq = '';									break;									case 'mssql_odbc':										$ary_type = $ary_name = array();										$ident_set = false;																				// Grab all of the data from current table.										$sql = "SELECT *											FROM $table_name";										$result = $db->sql_query($sql);										$retrieved_data = odbc_num_rows($result);										if ($retrieved_data)										{											$sql = "SELECT 1 as has_identity												FROM INFORMATION_SCHEMA.COLUMNS												WHERE COLUMNPROPERTY(object_id('$table_name'), COLUMN_NAME, 'IsIdentity') = 1";											$result2 = $db->sql_query($sql);											$row2 = $db->sql_fetchrow($result2);											if (!empty($row2['has_identity']))											{												$sql_data .= "\nSET IDENTITY_INSERT $table_name ON\nGO\n";												$ident_set = true;											}											$db->sql_freeresult($result2);										}										$i_num_fields = odbc_num_fields($result);										for ($i = 0; $i < $i_num_fields; $i++)										{											$ary_type[$i] = odbc_field_type($result, $i);											$ary_name[$i] = odbc_field_name($result, $i);										}										while ($row = $db->sql_fetchrow($result))										{											$schema_vals = $schema_fields = array();											// Build the SQL statement to recreate the data.											for ($i = 0; $i < $i_num_fields; $i++)											{												$str_val = $row[$ary_name[$i]];												if (preg_match('#char|text|bool|varbinary#i', $ary_type[$i]))												{													$str_quote = "'";													$str_empty = '';													$str_val = addslashes($str_val);												}												else if (preg_match('#date|timestamp#i', $ary_type[$i]))												{													if (empty($str_val))													{														$str_quote = '';													}													else													{														$str_quote = "'";													}												}												else												{													$str_quote = '';													$str_empty = 'NULL';												}												if (empty($str_val) && $str_val !== '0' && !(is_int($str_val) || is_float($str_val)))												{													$str_val = $str_empty;												}												$schema_vals[$i] = $str_quote . $str_val . $str_quote;												$schema_fields[$i] = $ary_name[$i];											}											// Take the ordered fields and their associated data and build it											// into a valid sql statement to recreate that field in the data.											$sql_data .= "INSERT INTO $table_name (" . implode(', ', $schema_fields) . ') VALUES (' . implode(', ', $schema_vals) . ");\n";											if ($store == true)											{												$write($fp, $sql_data);											}											if ($download == true)											{												if (!empty($oper))												{													echo $oper($sql_data);												}												else												{													echo $sql_data;												}											}											$sql_data = '';										}										$db->sql_freeresult($result);										if ($retrieved_data)										{											$sql_data = "\nGO\n";											if ($ident_set)											{												$sql_data .= "\nSET IDENTITY_INSERT $table_name OFF\nGO\n";											}										}									break;									case 'mssql':										$ary_type = $ary_name = array();										$ident_set = false;																				// Grab all of the data from current table.										$sql = "SELECT *											FROM $table_name";										$result = $db->sql_query($sql);										$retrieved_data = mssql_num_rows($result);										$i_num_fields = mssql_num_fields($result);										for ($i = 0; $i < $i_num_fields; $i++)										{											$ary_type[$i] = mssql_field_type($result, $i);											$ary_name[$i] = mssql_field_name($result, $i);										}										if ($retrieved_data)										{											$sql = "SELECT 1 as has_identity												FROM INFORMATION_SCHEMA.COLUMNS												WHERE COLUMNPROPERTY(object_id('$table_name'), COLUMN_NAME, 'IsIdentity') = 1";											$result2 = $db->sql_query($sql);											$row2 = $db->sql_fetchrow($result2);											if (!empty($row2['has_identity']))											{												$sql_data .= "\nSET IDENTITY_INSERT $table_name ON\nGO\n";												$ident_set = true;											}											$db->sql_freeresult($result2);										}										while ($row = $db->sql_fetchrow($result))										{											$schema_vals = $schema_fields = array();											// Build the SQL statement to recreate the data.											for ($i = 0; $i < $i_num_fields; $i++)											{												$str_val = $row[$ary_name[$i]];												if (preg_match('#char|text|bool|varbinary#i', $ary_type[$i]))												{													$str_quote = "'";													$str_empty = '';													$str_val = addslashes($str_val);												}												else if (preg_match('#date|timestamp#i', $ary_type[$i]))												{													if (empty($str_val))													{														$str_quote = '';													}													else													{														$str_quote = "'";													}												}												else												{													$str_quote = '';													$str_empty = 'NULL';												}												if (empty($str_val) && $str_val !== '0' && !(is_int($str_val) || is_float($str_val)))												{													$str_val = $str_empty;												}												$schema_vals[$i] = $str_quote . $str_val . $str_quote;												$schema_fields[$i] = $ary_name[$i];											}											// Take the ordered fields and their associated data and build it											// into a valid sql statement to recreate that field in the data.											$sql_data .= "INSERT INTO $table_name (" . implode(', ', $schema_fields) . ') VALUES (' . implode(', ', $schema_vals) . ");\n";											if ($store == true)											{												$write($fp, $sql_data);											}											if ($download == true)											{												if (!empty($oper))												{													echo $oper($sql_data);												}												else												{													echo $sql_data;												}											}											$sql_data = '';										}										$db->sql_freeresult($result);										if ($retrieved_data)										{											$sql_data = "\nGO\n";											if ($ident_set)											{												$sql_data .= "\nSET IDENTITY_INSERT $table_name OFF\nGO\n";											}										}									break;									case 'firebird':										$ary_type = $ary_name = array();																				// Grab all of the data from current table.										$sql = "SELECT *											FROM $table_name";										$result = $db->sql_query($sql);										$i_num_fields = ibase_num_fields($result);										for ($i = 0; $i < $i_num_fields; $i++)										{											$info = ibase_field_info($result, $i);											$ary_type[$i] = $info['type'];											$ary_name[$i] = $info['name'];										}										while ($row = $db->sql_fetchrow($result))										{											$schema_vals = $schema_fields = array();											// Build the SQL statement to recreate the data.											for ($i = 0; $i < $i_num_fields; $i++)											{												$str_val = $row[strtolower($ary_name[$i])];												if (preg_match('#char|text|bool|varbinary#i', $ary_type[$i]))												{													$str_quote = "'";													$str_empty = '';													$str_val = addslashes($str_val);												}												else if (preg_match('#date|timestamp#i', $ary_type[$i]))												{													if (empty($str_val))													{														$str_quote = '';													}													else													{														$str_quote = "'";													}												}												else												{													$str_quote = '';													$str_empty = 'NULL';												}												if (empty($str_val) && $str_val !== '0')												{													$str_val = $str_empty;												}												$schema_vals[$i] = $str_quote . $str_val . $str_quote;												$schema_fields[$i] = "'" . $ary_name[$i] . "'";											}											// Take the ordered fields and their associated data and build it											// into a valid sql statement to recreate that field in the data.											$sql_data .= "INSERT INTO $table_name (" . implode(', ', $schema_fields) . ') VALUES (' . implode(', ', $schema_vals) . ");\n";											if ($store == true)											{												$write($fp, $sql_data);											}											if ($download == true)											{												if (!empty($oper))												{													echo $oper($sql_data);												}												else												{													echo $sql_data;												}											}											$sql_data = '';										}										$db->sql_freeresult($result);									break;									case 'oracle':										$ary_type = $ary_name = array();																				// Grab all of the data from current table.										$sql = "SELECT *											FROM $table_name";										$result = $db->sql_query($sql);										$i_num_fields = ocinumcols($result);										for ($i = 0; $i < $i_num_fields; $i++)										{											$ary_type[$i] = ocicolumntype($result, $i);											$ary_name[$i] = ocicolumnname($result, $i);										}										while ($row = $db->sql_fetchrow($result))										{											$schema_vals = $schema_fields = array();											// Build the SQL statement to recreate the data.											for ($i = 0; $i < $i_num_fields; $i++)											{												$str_val = $row[$ary_name[$i]];												if (preg_match('#char|text|bool|raw#i', $ary_type[$i]))												{													$str_quote = "'";													$str_empty = '';													$str_val = addslashes($str_val);												}												else if (preg_match('#date|timestamp#i', $ary_type[$i]))												{													if (empty($str_val))													{														$str_quote = '';													}													else													{														$str_quote = "'";													}												}												else												{													$str_quote = '';													$str_empty = 'NULL';												}												if (empty($str_val) && $str_val !== '0')												{													$str_val = $str_empty;												}												$schema_vals[$i] = $str_quote . $str_val . $str_quote;												$schema_fields[$i] = '"' . $ary_name[$i] . "'";											}											// Take the ordered fields and their associated data and build it											// into a valid sql statement to recreate that field in the data.											$sql_data .= "INSERT INTO $table_name (" . implode(', ', $schema_fields) . ') VALUES (' . implode(', ', $schema_vals) . ");\n";											if ($store == true)											{												$write($fp, $sql_data);											}											if ($download == true)											{												if (!empty($oper))												{													echo $oper($sql_data);												}												else												{													echo $sql_data;												}											}											$sql_data = '';										}										$db->sql_freeresult($result);									break;								}							}						}						switch ($db->sql_layer)						{							case 'sqlite':							case 'postgres':								$sql_data .= "COMMIT;";							break;							case 'mssql':							case 'mssql_odbc':								$sql_data .= "COMMIT\nGO";							break;						}												if ($store == true)						{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -