@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | public function __construct($db = null, $queryParser = null, $resultHandler = null, $path = '/') |
| 22 | 22 | { |
| 23 | - $this->db = $db; |
|
| 23 | + $this->db = $db; |
|
| 24 | 24 | if ($this->db) { |
| 25 | 25 | $this->db->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); |
| 26 | 26 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public function cd($path) |
| 38 | 38 | { |
| 39 | - return new self( $this->db, $this->queryParser, $this->resultHandler, \arc\path::collapse($path, $this->path) ); |
|
| 39 | + return new self($this->db, $this->queryParser, $this->resultHandler, \arc\path::collapse($path, $this->path)); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | * @param string $path |
| 46 | 46 | * @return mixed |
| 47 | 47 | */ |
| 48 | - public function find($query, $path='') |
|
| 48 | + public function find($query, $path = '') |
|
| 49 | 49 | { |
| 50 | 50 | $path = \arc\path::collapse($path, $this->path); |
| 51 | 51 | $sql = $this->queryParser->parse($query, $path); |
| 52 | - return ($this->resultHandler)( $sql, [] ); |
|
| 52 | + return ($this->resultHandler)($sql, []); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @param string $path |
| 58 | 58 | * @return mixed |
| 59 | 59 | */ |
| 60 | - public function get($path='') |
|
| 60 | + public function get($path = '') |
|
| 61 | 61 | { |
| 62 | 62 | $path = \arc\path::collapse($path, $this->path); |
| 63 | 63 | $parent = ($path=='/' ? '' : \arc\path::parent($path)); |
@@ -78,9 +78,9 @@ discard block |
||
| 78 | 78 | * @param string $top |
| 79 | 79 | * @return mixed |
| 80 | 80 | */ |
| 81 | - public function parents($path='', $top='/') |
|
| 81 | + public function parents($path = '', $top = '/') |
|
| 82 | 82 | { |
| 83 | - $path = \arc\path::collapse($path, $this->path); |
|
| 83 | + $path = \arc\path::collapse($path, $this->path); |
|
| 84 | 84 | return ($this->resultHandler)( |
| 85 | 85 | /** @lang sql */ |
| 86 | 86 | 'path=substring(:path,1,length(path)) ' |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | * @param string $path |
| 95 | 95 | * @return mixed |
| 96 | 96 | */ |
| 97 | - public function ls($path='') |
|
| 97 | + public function ls($path = '') |
|
| 98 | 98 | { |
| 99 | - $path = \arc\path::collapse($path, $this->path); |
|
| 99 | + $path = \arc\path::collapse($path, $this->path); |
|
| 100 | 100 | return ($this->resultHandler)('parent=:path', [':path' => $path]); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * @param string $path |
| 106 | 106 | * @return bool |
| 107 | 107 | */ |
| 108 | - public function exists($path='') |
|
| 108 | + public function exists($path = '') |
|
| 109 | 109 | { |
| 110 | 110 | $path = \arc\path::collapse($path, $this->path); |
| 111 | 111 | $query = $this->db->prepare('select count(*) from nodes where path=:path'); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function initialize() { |
| 121 | 121 | try { |
| 122 | - if ($result=$this->exists('/')) { |
|
| 122 | + if ($result = $this->exists('/')) { |
|
| 123 | 123 | return false; |
| 124 | 124 | } |
| 125 | 125 | } catch (\PDOException $e) { |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | SQL; |
| 144 | 144 | // $queries[] = "create trigger before_insert_node before insert on nodes for each row set new.id = UUID_TO_BIN(uuid());"; |
| 145 | 145 | $queries[] = "create unique index path on nodes ( path(255) );"; |
| 146 | - foreach ( $queries as $query ) { |
|
| 146 | + foreach ($queries as $query) { |
|
| 147 | 147 | $result = $this->db->exec($query); |
| 148 | 148 | if ($result===false) { |
| 149 | 149 | $this->db->exec('rollback;'); |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | return $this->save(\arc\prototype::create([ |
| 156 | 156 | 'name' => 'Root' |
| 157 | - ]),'/'); |
|
| 157 | + ]), '/'); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * @param string $path |
| 164 | 164 | * @return mixed |
| 165 | 165 | */ |
| 166 | - public function save($data, $path='') { |
|
| 166 | + public function save($data, $path = '') { |
|
| 167 | 167 | $path = \arc\path::collapse($path, $this->path); |
| 168 | 168 | $parent = ($path=='/' ? '' : \arc\path::parent($path)); |
| 169 | 169 | if ($path!='/' && !$this->exists($parent)) { |