Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
antSword
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
HuangJunbo
antSword
Commits
9f720029
Commit
9f720029
authored
Mar 17, 2019
by
Medicean
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(Enhance:Database) php pdo 驱动检测
parent
47402e6b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
6 deletions
+63
-6
base.js
source/core/php/template/base.js
+5
-0
postgresql_pdo.js
source/core/php/template/database/postgresql_pdo.js
+58
-6
No files found.
source/core/php/template/base.js
View file @
9f720029
...
...
@@ -10,5 +10,10 @@ module.exports = () => ({
`$m=array('mysql_close','mysqli_close','mssql_close','sqlsrv_close','ora_close','oci_close','ifx_close','sqlite_close','pg_close','dba_close','dbmclose','filepro_fieldcount','sybase_close');
foreach ($m as $f) {
echo($f."\\t".(function_exists($f)?'1':'0')."\\n");
}
if(function_exists('pdo_drivers')){
foreach(@pdo_drivers() as $f){
echo("pdo_".$f."\\t1\\n");
}
}`
.
replace
(
/
\n\s
+/g
,
''
),
})
source/core/php/template/database/postgresql_pdo.js
View file @
9f720029
...
...
@@ -13,7 +13,18 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
$pwd=$m?stripslashes($_POST["
${
arg3
}
"]):$_POST["
${
arg3
}
"];
$host=split(':',$hst)[0];
$port=split(':',$hst)[1];
$dbh=new PDO("pgsql:host=$host;port=$port;dbname=postgres;",$usr,$pwd);
$arr=array(
'host'=>$host,
'port'=>$port,
);
$cs='pgsql:';
foreach($arr as $k=>$v) {
if(empty($v)){
continue;
}
$cs .= "$k=$v;";
}
$dbh=new PDO($cs,$usr,$pwd);
if(!$dbh){
echo("ERROR://CONNECT ERROR");
}else{
...
...
@@ -39,7 +50,19 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
$dbn=$m?stripslashes($_POST["
${
arg4
}
"]):$_POST["
${
arg4
}
"];
$host=split(':',$hst)[0];
$port=split(':',$hst)[1];
$dbh=new PDO("pgsql:host=$host;port=$port;dbname=$dbn;",$usr,$pwd);
$arr=array(
'host'=>$host,
'port'=>$port,
'dbname'=>$dbn,
);
$cs='pgsql:';
foreach($arr as $k=>$v) {
if(empty($v)){
continue;
}
$cs .= "$k=$v;";
}
$dbh=new PDO($cs,$usr,$pwd);
if(!$dbh){
echo("ERROR://CONNECT ERROR");
}else{
...
...
@@ -67,7 +90,19 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
$tab=$m?stripslashes($_POST["
${
arg5
}
"]):$_POST["
${
arg5
}
"];
$host=split(':',$hst)[0];
$port=split(':',$hst)[1];
$dbh=new PDO("pgsql:host=$host;port=$port;dbname=$dbn;",$usr,$pwd);
$arr=array(
'host'=>$host,
'port'=>$port,
'dbname'=>$dbn,
);
$cs='pgsql:';
foreach($arr as $k=>$v) {
if(empty($v)){
continue;
}
$cs .= "$k=$v;";
}
$dbh=new PDO($cs,$usr,$pwd);
if(!$dbh){
echo("ERROR://CONNECT ERROR");
}else{
...
...
@@ -98,14 +133,30 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
$encode=$m?stripslashes($_POST["
${
arg6
}
"]):$_POST["
${
arg6
}
"];
$host=split(':',$hst)[0];
$port=split(':',$hst)[1];
$dbh=new PDO("pgsql:host=$host;port=$port;dbname=$dbn;",$usr,$pwd);
$arr=array(
'host'=>$host,
'port'=>$port,
'dbname'=>$dbn,
);
$cs='pgsql:';
foreach($arr as $k=>$v) {
if(empty($v)){
continue;
}
$cs .= "$k=$v;";
}
$dbh=new PDO($cs,$usr,$pwd);
if(!$dbh){
echo("ERROR://CONNECT ERROR");
}else{
$result=$dbh->prepare($sql);
if(!$result->execute()){
echo("Status\t|\t\r\n");
echo(base64_encode("ERROR://EXECUTE ERROR")."\t|\t\r\n");
$err="";
foreach(@$result->errorInfo() as $v){
$err.=$v." ";
}
echo(base64_encode("ERROR://".$err)."\t|\t\r\n");
}else{
$bool=True;
while($res=$result->fetch(PDO::FETCH_ASSOC)){
...
...
@@ -122,10 +173,11 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
echo "\r\n";
}
if($bool){
if(
$result->row
Count()){
if(
!$result->column
Count()){
echo("Affect Rows\t|\t\r\n".base64_encode($result->rowCount())."\t|\t\r\n");
}else{
echo("Status\t|\t\r\n");
echo(base64_encode("ERROR://Table is empty.")."\t|\t\r\n");
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment