File: move.php

package info (click to toggle)
jquery-goodies 12-1.1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,376 kB
  • sloc: xml: 308; makefile: 82; php: 48; sql: 39
file content (17 lines) | stat: -rw-r--r-- 462 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php

/**
 * PUT /move.php?id=3&to=6
 *
 * Moves node with id 3 to it's new parent with id 6.
 */
$parent_id = substr($_POST['to'], 5);
$id = substr($_POST['id'], 5);

$dbh = new PDO('sqlite:db/database.sqlite3');
$sth = $dbh->prepare('UPDATE items SET parent_id = :parent_id WHERE id = :id');
$passed = $sth->execute(array(':parent_id' => (int) $parent_id, ':id' => (int) $id));

echo $passed ? "Moving {$id} to {$parent_id}" : var_dump($sth->errorInfo());

?>