ó ä@Qc@s2ddlmZmZddlZddlZddlmZmZmZm Z m Z m Z m Z m Z mZedddddd ƒZejd d d d ejƒgddƒejejejjƒd„ƒƒZd„Zejdd dd ejƒgddƒejejejjƒd„ƒƒZdS(iÿÿÿÿ(t DefineModuletwbinputsN( t node_valuet node_symbolt node_childrentfind_child_nodetfind_child_nodesttrim_astt ASTHelpert dump_treet flatten_nodetnamet CodeUtilstauthors Oracle Corp.tversions1.0swb.sqlide.copyAsPHPConnecttcaptions$Copy as PHP Code (Connect to Server)tinputt pluginMenus SQL/UtilitiescCsì|jrè|j}|jjdkraidd6dd6|jdd6|jdd6|jd 6}nTi|jd d6|jdrŒ|jdndd6|jdd6d d6|jd 6}d |}tjj|ƒtjj ƒj d ƒndS(sPCopies PHP code to connect to the active MySQL connection to the clipboard. tMysqlNativeSockets p:localhostthostiê tporttuserNametusertsockettdbnamethostNamets$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(); sCopied PHP code to clipboardi( t connectiontdriverR tparameterValuest defaultSchematmformst Utilitiestset_clipboard_texttApptgettset_status_text(teditortconntparamsttext((s..\modules\code_utils_grt.pytcopyAsPHPConnects&  !  cCsöddlm}|j|ƒ}xÐ|D]È}t|ƒtkrDq&q&|\}}}}}} t|ƒ} t| dƒ} | r&g} g} d}x"t| ƒD]}t|ƒdkrœtt|dƒdƒ}|s”t|dƒ}|rt t|ƒƒd krt|ƒd}ntt|d ƒdƒ}|r?t |ƒ}q d }t |ƒ}|r ddl }|j d |ƒ}|r‘|jƒd}q‘q n t |ƒ}| j|ƒqœqœWt|ƒ}|j|ƒ\}}|||!}|}t|d ƒ}xpt|ƒD]b}|j|ƒ\}}||8}||8}|||!}|| d||}| jd|ƒqWi}xnt| ƒD]`\}}|j|ƒrÃd|||f| |<||cd7ƒd6d jdgt|ƒƒd6|d6|d6} t j j | ƒt j j ƒjdƒdS(s"Copies PHP code to execute the query and iterate its results to the clipboard. The code will substitute @variables with parameter markers (?) and will bind them with matching PHP variables. The results will be bound to PHP variables matching the SELECTed column names or their aliases. s t s t;iÿÿÿÿRs $%s = '';is]$stmt->bind_param('%s', %s); //FIXME: param types: s- string, i- integer, d- double, b- blob REs, t$tfield1tfield2sý$query = "%(query)s"; %(vars)s %(var_bind)s if ($stmt = $con->prepare($query)) { $stmt->execute(); $stmt->bind_result(%(column_list)s); while ($stmt->fetch()) { //printf("%(fmt_list)s\n", %(column_list)s); } $stmt->close(); }t"s\"RBs$%st column_lists%stfmt_listRVtvar_bindsCopied PHP code to clipboardiN(t selectedTexttscriptRZtNonetreplacetstriptendswithtjoinR8RR R!R"R#R$( tqbuffertsqltrest column_namestvariable_namestvariable_assignmentst variable_bindRWRGR(((s..\modules\code_utils_grt.pytcopyAsPHPQueryAndFetchys. $ .A D (twbRRtgrtRtsql_reformatterRRRRRRRR R t ModuleInfotplugintcurrentSQLEditortexporttINTtclassestdb_query_EditorR)RZtcurrentQueryBuffertdb_query_QueryBufferRr(((s..\modules\code_utils_grt.pyts  @'') A'