Skip to content

Commit 7f476da

Browse files
committed
Merge branch 'master' of github.com:mevdschee/php-crud-api
2 parents 6fa2e04 + 1da0583 commit 7f476da

File tree

10 files changed

+69
-33
lines changed

10 files changed

+69
-33
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,3 +760,25 @@ To run the docker tests run "build_all.sh" and "run_all.sh" from the docker dire
760760
sqlsrv: skipped, driver not loaded
761761

762762
The above test run (including starting up the databases) takes less than one minute on my machine.
763+
764+
$ ./run.sh
765+
1) debian9
766+
2) ubuntu16
767+
3) ubuntu18
768+
> 3
769+
================================================
770+
Ubuntu 18.04
771+
================================================
772+
[1/4] Starting MySQL 5.7 ........ done
773+
[2/4] Starting PostgreSQL 10.4 .. done
774+
[3/4] Starting SQLServer 2017 ... skipped
775+
[4/4] Cloning PHP-CRUD-API v2 ... skipped
776+
------------------------------------------------
777+
mysql: 84 tests ran in 2899 ms, 0 failed
778+
pgsql: 84 tests ran in 380 ms, 0 failed
779+
sqlsrv: skipped, driver not loaded
780+
root@b7ab9472e08f:/php-crud-api#
781+
782+
As you can see the "run.sh" script gives you access to a prompt in a chosen the docker environment.
783+
In this environment the local files are mounted. This allows for easy debugging on different environments.
784+
You may type "exit" when you are done.

api.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,15 +1774,16 @@ private function getOptions(): array
17741774
$options = array(
17751775
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
17761776
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
1777-
\PDO::ATTR_PERSISTENT => true,
17781777
);
17791778
switch ($this->driver) {
17801779
case 'mysql':return $options + [
17811780
\PDO::ATTR_EMULATE_PREPARES => false,
17821781
\PDO::MYSQL_ATTR_FOUND_ROWS => true,
1782+
\PDO::ATTR_PERSISTENT => true,
17831783
];
17841784
case 'pgsql':return $options + [
17851785
\PDO::ATTR_EMULATE_PREPARES => false,
1786+
\PDO::ATTR_PERSISTENT => true,
17861787
];
17871788
case 'sqlsrv':return $options + [
17881789
\PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE => true,
@@ -2803,7 +2804,7 @@ public function __construct(Router $router, Responder $responder, array $propert
28032804
$this->reflection = $reflection;
28042805
}
28052806

2806-
private function handleColumns(String $method, String $path, String $databaseName, String $tableName/*: void*/
2807+
private function handleColumns(String $method, String $path, String $databaseName, String $tableName) /*: void*/
28072808
{
28082809
$columnHandler = $this->getProperty('columnHandler', '');
28092810
if ($columnHandler) {
@@ -2817,7 +2818,7 @@ private function handleColumns(String $method, String $path, String $databaseNam
28172818
}
28182819
}
28192820

2820-
private function handleTable(String $method, String $path, String $databaseName, String $tableName/*: void*/
2821+
private function handleTable(String $method, String $path, String $databaseName, String $tableName) /*: void*/
28212822
{
28222823
if (!$this->reflection->hasTable($tableName)) {
28232824
return;
@@ -2833,7 +2834,7 @@ private function handleTable(String $method, String $path, String $databaseName,
28332834
}
28342835
}
28352836

2836-
private function handleJoinTables(String $method, String $path, String $databaseName, array $joinParameters/*: void*/
2837+
private function handleJoinTables(String $method, String $path, String $databaseName, array $joinParameters) /*: void*/
28372838
{
28382839
$uniqueTableNames = array();
28392840
foreach ($joinParameters as $joinParameter) {
@@ -2847,7 +2848,7 @@ private function handleJoinTables(String $method, String $path, String $database
28472848
}
28482849
}
28492850

2850-
private function handleAllTables(String $method, String $path, String $databaseName/*: void*/
2851+
private function handleAllTables(String $method, String $path, String $databaseName) /*: void*/
28512852
{
28522853
$tableNames = $this->reflection->getTableNames();
28532854
foreach ($tableNames as $tableName) {
@@ -3231,7 +3232,7 @@ private function set(String $path, String $value) /*: void*/
32313232
$current = $value;
32323233
}
32333234

3234-
public function setPaths(DatabaseDefinition $database/*: void*/
3235+
public function setPaths(DatabaseDefinition $database) /*: void*/
32353236
{
32363237
$result = [];
32373238
foreach ($database->getTables() as $database) {
@@ -3847,7 +3848,7 @@ class PathTree implements \JsonSerializable
38473848

38483849
private $tree;
38493850

3850-
public function __construct(object &$tree = null)
3851+
public function __construct( /* object */&$tree = null)
38513852
{
38523853
if (!$tree) {
38533854
$tree = $this->newTree();

docker/build_all.sh

100644100755
File mode changed.

docker/clean_all.sh

100644100755
File mode changed.

docker/debian9/run.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ echo "skipped"
4444

4545
echo -n "[4/4] Cloning PHP-CRUD-API v2 ... "
4646
# install software
47-
git clone --quiet https://github.com/mevdschee/php-crud-api.git
48-
echo "done"
47+
if [ -d /php-crud-api ]; then
48+
echo "skipped"
49+
else
50+
git clone --quiet https://github.com/mevdschee/php-crud-api.git
51+
echo "done"
52+
fi
4953

5054
echo "------------------------------------------------"
5155

docker/debug.sh

Lines changed: 0 additions & 20 deletions
This file was deleted.

docker/run.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
FILES=*
3+
i=0
4+
options=()
5+
for f in $FILES; do
6+
if [[ -d "$f" ]]; then
7+
((i++))
8+
options[$i]=$f
9+
fi
10+
done
11+
PS3="> "
12+
select f in "${options[@]}"; do
13+
if (( REPLY > 0 && REPLY <= ${#options[@]} )); then
14+
break
15+
else
16+
exit
17+
fi
18+
done
19+
dir=$(readlink -f ..)
20+
docker rm "php-crud-api_$f" > /dev/null 2>&1
21+
docker run -ti -v $dir:/php-crud-api --name "php-crud-api_$f" "php-crud-api:$f" /bin/bash -c '/usr/sbin/docker-run && cd php-crud-api && /bin/bash'

docker/run_all.sh

100644100755
File mode changed.

docker/ubuntu16/run.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@ echo "done"
5959

6060
echo -n "[4/4] Cloning PHP-CRUD-API v2 ... "
6161
# install software
62-
git clone --quiet https://github.com/mevdschee/php-crud-api.git
63-
echo "done"
62+
if [ -d /php-crud-api ]; then
63+
echo "skipped"
64+
else
65+
git clone --quiet https://github.com/mevdschee/php-crud-api.git
66+
echo "done"
67+
fi
6468

6569
echo "------------------------------------------------"
6670

docker/ubuntu18/run.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ echo "skipped"
4646

4747
echo -n "[4/4] Cloning PHP-CRUD-API v2 ... "
4848
# install software
49-
git clone --quiet https://github.com/mevdschee/php-crud-api.git
50-
echo "done"
49+
if [ -d /php-crud-api ]; then
50+
echo "skipped"
51+
else
52+
git clone --quiet https://github.com/mevdschee/php-crud-api.git
53+
echo "done"
54+
fi
5155

5256
echo "------------------------------------------------"
5357

0 commit comments

Comments
 (0)