php - MYSQL to sqlsrv -


Working on converting my mysql php code into sqlsrv, but there is a problem finding the same task.

This code is:

  $ result = sqlsrv_query ($ conn, $ sql) or die ("The query can not be executed: & lt; br & Gt; "Sqlsrv_error ()." & Lt; br & gt; "sqlsrv_errno ()); $ File_ending = "xls"; $ Reals = array (); // Header Info for Browser Header ("Content-Type: App / Xls"); Header ("content-dispute: attachment; file name = $ filename.xls"); Header ("Prestama: no-cache"); Header ("End: 0"); / ******* Start formatting for Excel ******* / // Define Separator (defines columns in excel and tab in the word) $ sep = "\ t"; // Tabbed Character // The name of the printing column names as the name of the MySQL field / * ($ i = 0; $ i & lt; slslsrv_num_fields ($ result); $ i ++) {$ type = sqlsrv_field_metadata ($ result , $ I); Echo sqlsrv_field_metadata ($ result, $ i). "\ T"; If ($ type == "actual") {$ reals [] = $ i; }} * / $ I = 0; Foreign currency (sqlsrv_field_metadata ($ result) as $ field metadata) {echo $ field matadata ["name"] + "\ t"; If ($ field matadata ["type"] == "actual") // $ field matadata ["type"] === SQL_REAL {$ reals [] = $ i; } $ i ++; } Print ("\ n"); // Start the end of the calling names // Get the loop data ($ line = sqlsrv_num_rows ($ result)) {$ schema_insert = ""; ($ J = 0; $ j & lt; sqlsrv_num_fields ($ result); $ j ++) {if (! Isset ($ line [$ j])) $ schema_intert = "NULL". $ Sep; Otherwise ($ line [$ j]! = "") {If (array_year ($ j, $ real)) {$ schema_nert = Str_replace (".", ",", "$ Row [$ j]") $ September; } And {$ Schema_Intern. = "$ Line [$ j]". $ Sep; }} And $ Schema_Inter = "". $ Sep; } $ Schema_interest = str_replace ($ sep. "$", "", $ Schema_inte); $ Schema_interface = preg_realest ("/ \ r \ n | \ n \ r | \ n | \ r /", "", $ schema_interest); $ Schema_interts = "\ T"; Print (trim ($ schema_insert)); Print "\ n"; }   

I'm not sure that field_type and field_name is equivalent to sqlsrv, but it does not work:

 for  ($ i = 0; $ I & lt; sqlsrv_num_fields ($ result); $ i ++) {$ type = sqlsrv_get_field ($ result, $ i); Echo sqlsrv_get_field ($ result, $ i). "\ T"; If ($ type == "actual") {$ reals [] = $ i; I'm an ASP.NET developer with a lot of information about PHP. Just check it out once something like that will be useful to you.  
  $ stmt = sqlsrv_prepare ($ conn, $ sql); $ Result = sqlsrv_query ($ conn, $ sql); $ I = =; Foreign currency (sqlsrv_field_metadata ($ stmt) $ as field metadata) {echo $ field matadata ["name"] + "\ t"; If ($ field matadata ["type"] == "actual") // $ field matadata ["type"] === SQL_REAL {$ reals [] = $ i} $ i ++; }   

I did not run it before posting here, please tell me that it is not working.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -