$row = PicDB::fetch($select, "one"); class PicPathAccessException extends Exception { public $mode; public $idType; public $label; public static function initE($mode, $idType, $label) { $e = new self(); $e->mode = $mode; $e->idType = $idType; $e->label = $label; throw $e; } } if ($row && $mode === "add") { PicPathAccessException::initE($mode, $idType, $label); } elseif (!$row && $mode === "remove") { PicPathAccessException::initE($mode, $idType, $label); } if ($mode === "add") { $insert = PicDB::newInsert(); $insert->into("path_access")->cols(array("path_id" => $pathID, "auth_type" => $authType, "id_type" => $idType, "auth_id" => $id)); PicDB::crud($insert); } elseif ($mode === "remove") { $delete = PicDB::newDelete(); $delete->from("path_access")->where("id = :id")->bindValue("id", $row["id"]); PicDB::crud($delete); } PicConfCache::remove("pathauth.json"); PicCLI::success();
<?php PicCLI::initGetopt(array()); $io = PicCLI::getIO(); if (!($name = PicCLI::getGetopt(1))) { $name = PicCLI::prompt("Name"); if (!$name) { $io->errln("No name specified."); exit(PicCLI::EXIT_INPUT); } } loadPicFile("classes/db.php"); PicDB::initDB(); $insert = PicDB::newInsert(); $insert->into("groups")->cols(array("name" => $name)); PicDB::crud($insert); PicCLI::success();