Skip to content

Commit 3f8b0a9

Browse files
committed
Patch-A
1 parent 9be4b9b commit 3f8b0a9

File tree

79 files changed

+1433
-333
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1433
-333
lines changed

build.gradle

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -56,47 +56,49 @@ allprojects {
5656

5757
subprojects {
5858
if (it.name.startsWith("develnext-bundles")) {
59-
def dirName = file(it.name).name;
60-
def bundleDir = "${projectDir}/../../develnext/misc/library/bundles/${dirName}/";
59+
if (file("$projectDir/.resource").exists()) {
60+
def dirName = file(it.name).name;
61+
def bundleDir = "${projectDir}/../../develnext/misc/library/bundles/${dirName}/";
6162

62-
clean {
63-
delete bundleDir
64-
}
63+
clean {
64+
delete bundleDir
65+
}
6566

66-
jar {
67-
doLast {
68-
copy {
69-
from jar.archivePath
70-
from(configurations.runtime) {
71-
exclude '**/jphp-runtime-*.jar'
72-
}
67+
jar {
68+
doLast {
69+
copy {
70+
from jar.archivePath
71+
from(configurations.runtime) {
72+
exclude '**/jphp-runtime-*.jar'
73+
}
7374

74-
into bundleDir
75-
}
75+
into bundleDir
76+
}
7677

77-
copy {
78-
from "$projectDir/.resource"
79-
into "$bundleDir/.."
80-
rename ".resource", "${dirName}.resource"
81-
}
78+
copy {
79+
from "$projectDir/.resource"
80+
into "$bundleDir/.."
81+
rename ".resource", "${dirName}.resource"
82+
}
8283

83-
fileTree(bundleDir).visit { FileVisitDetails el ->
84-
def name = el.getName()
84+
fileTree(bundleDir).visit { FileVisitDetails el ->
85+
def name = el.getName()
8586

86-
if (name.endsWith(".jar")) {
87-
name = name.replaceAll(/(-[0-9]+|\.[0-9]+|-SNAPSHOT)/, "");
87+
if (name.endsWith(".jar")) {
88+
name = name.replaceAll(/(-[0-9]+|\.[0-9]+|-SNAPSHOT)/, "");
8889

89-
if (!name.equals(el.getName())) {
90-
println "Rename '" + el.file.parent + "/" + name + "' file"
90+
if (!name.equals(el.getName())) {
91+
println "Rename '" + el.file.parent + "/" + name + "' file"
9192

92-
def file = file(el.file.parent + "/" + name)
93+
def file = file(el.file.parent + "/" + name)
9394

94-
if (file.exists()) {
95-
file.delete()
96-
}
95+
if (file.exists()) {
96+
file.delete()
97+
}
9798

98-
if (!el.file.renameTo(file)) {
99-
el.file.delete()
99+
if (!el.file.renameTo(file)) {
100+
el.file.delete()
101+
}
100102
}
101103
}
102104
}
@@ -207,6 +209,8 @@ project(':develnext') {
207209
//compile project(':develnext-bundles/dn-orientdb-bundle')
208210
provided project(':develnext-bundles/dn-jsoup-bundle')
209211
provided project(':develnext-bundles/dn-mail-bundle')
212+
provided project(':develnext-bundles/dn-sql-bundle')
213+
provided project(':develnext-bundles/dn-sqlite-bundle')
210214

211215
// stubs.
212216
compile project(':develnext-stubs/dn-php-sdk')
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name=SQL
2+
3+
class=develnext\\bundle\\sql\\SqlBundle
4+
hidden=true
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
project.version = ''
3+
4+
repositories {
5+
mavenLocal()
6+
jcenter()
7+
mavenCentral()
8+
}
9+
10+
sourceSets {
11+
main.resources.srcDirs = ['src']
12+
}
13+
14+
dependencies {
15+
compile "org.develnext.jphp:jphp-sql-ext:$rootProject.ext.jphpVersion"
16+
}
569 Bytes
Loading
374 Bytes
Loading
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
namespace develnext\bundle\sql;
3+
4+
use ide\bundle\AbstractBundle;
5+
use ide\bundle\AbstractJarBundle;
6+
use ide\formats\ScriptModuleFormat;
7+
use ide\Ide;
8+
use ide\project\behaviours\GuiFrameworkProjectBehaviour;
9+
use ide\project\Project;
10+
11+
class SqlBundle extends AbstractJarBundle
12+
{
13+
function getName()
14+
{
15+
return "JPHP SQL Extension";
16+
}
17+
18+
public function isAvailable(Project $project)
19+
{
20+
return true;
21+
}
22+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
bundle/sql/SqlClient.php
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
<?php
2+
namespace bundle\sql;
3+
4+
use php\framework\Logger;
5+
use php\gui\framework\AbstractScript;
6+
use php\sql\SqlConnection;
7+
use php\sql\SqlDriverManager;
8+
use php\sql\SqlException;
9+
use php\sql\SqlStatement;
10+
11+
/**
12+
* Class SqlClient
13+
* @package bundle\sql
14+
*/
15+
abstract class SqlClient extends AbstractScript
16+
{
17+
/**
18+
* @var SqlConnection
19+
*/
20+
private $client;
21+
22+
/**
23+
* @var bool
24+
*/
25+
private $closed = false;
26+
27+
/**
28+
* @var bool
29+
*/
30+
public $autoOpen = true;
31+
32+
/**
33+
* @var bool
34+
*/
35+
public $catchErrors = true;
36+
37+
/**
38+
* @return SqlConnection
39+
*/
40+
abstract protected function buildClient();
41+
42+
43+
/**
44+
* @param $target
45+
* @return mixed
46+
*/
47+
protected function applyImpl($target)
48+
{
49+
if ($this->autoOpen) {
50+
$this->open();
51+
}
52+
}
53+
54+
/**
55+
* Open database.
56+
*/
57+
public function open()
58+
{
59+
if (!$this->isOpened()) {
60+
$this->client = $this->buildClient();
61+
$this->closed = false;
62+
$this->trigger('open');
63+
}
64+
}
65+
66+
/**
67+
* @return bool
68+
*/
69+
public function isOpened()
70+
{
71+
return !$this->closed && !!$this->client;
72+
}
73+
74+
/**
75+
* Close connection.
76+
* @throws SqlException
77+
*/
78+
public function close()
79+
{
80+
$this->closed = true;
81+
82+
if ($this->client) {
83+
$this->client->close();
84+
}
85+
}
86+
87+
/**
88+
* @param array $sql
89+
* @param array $arguments
90+
* @return SqlStatement
91+
* @throws SqlException
92+
*/
93+
public function query($sql, $arguments = [])
94+
{
95+
try {
96+
return $this->client->query($sql, $arguments);
97+
} catch (SqlException $e) {
98+
if ($this->catchErrors) {
99+
$this->trigger('error', ['message' => $e->getMessage()]);
100+
Logger::error($e->getMessage() . " at line {$e->getLine()}, {$e->getFile()}");
101+
return null;
102+
} else {
103+
throw $e;
104+
}
105+
}
106+
}
107+
108+
/**
109+
* Makes all changes made since the previous
110+
* commit/rollback permanent and releases any database locks
111+
* currently held by this Connection object.
112+
*
113+
* @throws SqlException
114+
*/
115+
public function commit()
116+
{
117+
$this->client->commit();
118+
}
119+
120+
/**
121+
* Undoes all changes made in the current transaction
122+
* and releases any database locks currently held
123+
* by this Connection object.
124+
*
125+
* @throws SqlException
126+
*/
127+
public function rollback()
128+
{
129+
$this->client->rollback();
130+
}
131+
132+
public function __destruct()
133+
{
134+
if ($this->isOpened()) {
135+
$this->close();
136+
}
137+
}
138+
139+
public function free()
140+
{
141+
parent::free();
142+
143+
if ($this->isOpened()) {
144+
$this->close();
145+
}
146+
}
147+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name=SQLite
2+
description=Пакет для работы с бд SQLite 3
3+
4+
class=develnext\\bundle\\sql\\SqliteBundle
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
project.version = ''
3+
4+
repositories {
5+
mavenLocal()
6+
jcenter()
7+
mavenCentral()
8+
}
9+
10+
sourceSets {
11+
main.resources.srcDirs = ['src']
12+
}
13+
14+
dependencies {
15+
compile 'org.xerial:sqlite-jdbc:3.8.11.2'
16+
}

0 commit comments

Comments
 (0)