parameters: (editor)
return_statement: return 0
docstring: Copies PHP code to connect to the active MySQL connection to the clipboard.
docstring_summary: Copies PHP code to connect to the active MySQL connection to the clipboard.
docstring_tokens: Copies PHP code to connect to the active MySQL connection to the clipboard .
function: def copyAsPHPConnect(editor):
      """Copies PHP code to connect to the active MySQL connection to the clipboard.
      """
      if editor.connection:
          conn = editor.connection
          
          if conn.driver.name == "MysqlNativeSocket":
              params = {
              "host" : "p:localhost",
              "port" : 3306,
              "user" : conn.parameterValues["userName"],
              "socket" : conn.parameterValues["socket"],
              "dbname" : editor.defaultSchema
              }
          else:
              params = {
              "host" : conn.parameterValues["hostName"],
              "port" : conn.parameterValues["port"] if conn.parameterValues["port"] else 3306,
              "user" : conn.parameterValues["userName"],
              "socket" : "",
              "dbname" : editor.defaultSchema
              }
  
          text = """$host="%(host)s";
  $port=%(port)s;
  $socket="%(socket)s";
  $user="%(user)s";
  $password="";
  $dbname="%(dbname)s";
  
  $con = new mysqli($host, $user, $password, $dbname, $port, $socket)
  	or die ('Could not connect to the database server' . mysqli_connect_error());
  
  //$con->close();
  """ % params
          mforms.Utilities.set_clipboard_text(text)
          mforms.App.get().set_status_text("Copied PHP code to clipboard")
      return 0
function_tokens: def copyAsPHPConnect ( editor ) : if editor . connection : conn = editor . connection if conn . driver . name == "MysqlNativeSocket" : params = { "host" : "p:localhost" , "port" : 3306 , "user" : conn . parameterValues [ "userName" ] , "socket" : conn . parameterValues [ "socket" ] , "dbname" : editor . defaultSchema } else : params = { "host" : conn . parameterValues [ "hostName" ] , "port" : conn . parameterValues [ "port" ] if conn . parameterValues [ "port" ] else 3306 , "user" : conn . parameterValues [ "userName" ] , "socket" : "" , "dbname" : editor . defaultSchema } text = """$host="%(host)s";
  $port=%(port)s;
  $socket="%(socket)s";
  $user="%(user)s";
  $password="";
  $dbname="%(dbname)s";
  
  $con = new mysqli($host, $user, $password, $dbname, $port, $socket)
  	or die ('Could not connect to the database server' . mysqli_connect_error());
  
  //$con->close();
  """ % params mforms . Utilities . set_clipboard_text ( text ) mforms . App . get ( ) . set_status_text ( "Copied PHP code to clipboard" ) return 0