-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5240d58
Showing
2 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
if(isset($argv[1]) && $argv[1] != '') | ||
{ | ||
$all_names = []; | ||
|
||
$word = $argv[5]; | ||
$database = $argv[4]; | ||
$password = $argv[3]; | ||
$user = $argv[2]; | ||
$host = $argv[1]; | ||
|
||
$dblink = mysqli_connect($host, $user, $password, $database); | ||
|
||
if($word == 'prefixes') | ||
{ | ||
$sql_statement = "SELECT count(*) AS total FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '".$database."' AND ( COLUMN_NAME LIKE '".$argv[6]."%' )"; | ||
$result = $dblink->query($sql_statement); | ||
$data = mysqli_fetch_array($result); | ||
|
||
if($data['total']) | ||
{ | ||
echo 1; | ||
} | ||
exit; | ||
} | ||
else if(strpos($word,'.')) | ||
{ | ||
$words = explode('.',$word); | ||
$sql_statement = "SELECT COLUMN_NAME,TABLE_NAME,COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '".$database."' AND ( COLUMN_NAME LIKE '".$words[1]."%' AND TABLE_NAME = '".$words[0]."' )"; | ||
|
||
$result = $dblink->query($sql_statement); | ||
while($row = mysqli_fetch_array($result)) | ||
{ | ||
$all_names[$row['TABLE_NAME'].'.'.$row['COLUMN_NAME']] = $row['TABLE_NAME'].'.'.$row['COLUMN_NAME'].'//'.$row['COLUMN_TYPE']; | ||
} | ||
} | ||
else | ||
{ | ||
$sql_statement = "SELECT COLUMN_NAME,TABLE_NAME,COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '".$database."' AND ( COLUMN_NAME LIKE '".$word."%' OR TABLE_NAME LIKE '".$word."%' )"; | ||
|
||
$result = $dblink->query($sql_statement); | ||
while($row = mysqli_fetch_array($result)) | ||
{ | ||
if(strpos($row['COLUMN_NAME'],$word) === 0) | ||
{ | ||
$all_names[$row['COLUMN_NAME']] = $row['COLUMN_NAME'].'/'.$row['TABLE_NAME'].'/'.$row['COLUMN_TYPE']; | ||
} | ||
if(strpos($row['TABLE_NAME'],$word) === 0) | ||
{ | ||
$all_names[$row['TABLE_NAME']] = $row['TABLE_NAME'].'//table'; | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
mysqli_close($dblink); | ||
echo implode(';', $all_names); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
let g:path_myslq_plugin = expand('<sfile>:p:h') | ||
|
||
function! MyCompleteFunction( findstart, base ) | ||
if a:findstart | ||
let line = getline('.') | ||
let start = col('.') - 1 | ||
while start > 0 && line[start - 1] =~ '[A-Za-z_.]' | ||
let start -= 1 | ||
endwhile | ||
return start | ||
else | ||
let command = "!php ".g:path_myslq_plugin."/db.php '".g:database_host."' '".g:database_user."' '".g:database_password."' '".g:database_database."' '".a:base."'" | ||
redir =>output | ||
silent! exe command | ||
redir END | ||
let lenght = strlen(command) | ||
let lenght = lenght + 4 | ||
let outputLenght = strlen(output) | ||
let matches = split(output[ lenght : outputLenght ], ";") | ||
let result = [] | ||
for i in matches | ||
let exploded = split(i, "/") | ||
call add(result, {'word' : exploded[0], 'kind' : exploded[2], 'menu' : exploded[1]}) ", 'info': 'int' | ||
endfor | ||
return result | ||
endif | ||
endfunction | ||
|
||
|
||
function! DatabasePrefixesInit(word) | ||
let command = "!php ".g:path_myslq_plugin."/db.php '".g:database_host."' '".g:database_user."' '".g:database_password."' '".g:database_database."' 'prefixes' '".a:word."'" | ||
redir =>output | ||
silent! exe command | ||
redir END | ||
let lenght = strlen(command) | ||
let lenght = lenght + 4 | ||
let outputLenght = strlen(output) | ||
return output[lenght:outputLenght] | ||
endfunction | ||
|
||
|