本文整理匯總了PHP中Connector::Insert方法的典型用法代碼示例。如果您正苦於以下問題:PHP Connector::Insert方法的具體用法?PHP Connector::Insert怎麽用?PHP Connector::Insert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Connector
的用法示例。
在下文中一共展示了Connector::Insert方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addDocument
public static function addDocument($document, $options)
{
$filename = $document["name"];
// Check for upload error
if ($document["error"]) {
throw new InvalidArgumentException("Une erreur s'est produite lors de l'envoi du fichier (" . $document["error"] . ")");
}
// Determining the folder to put the document in
if (preg_match("/A[12]/", $options["promo"])) {
$destination = "A12/" . $filename;
} elseif (preg_match("/A[345]/", $options["promo"])) {
$destination = "A345/" . $filename;
} else {
$destination = $filename;
}
if (!move_uploaded_file($document["tmp_name"], __DIR__ . "/../../pdf/" . $destination)) {
error_log("Error when trying to write " . __DIR__ . "/../../pdf/" . $destination);
}
foreach ($options as $key => $value) {
if (empty($value) && $key != "promo") {
throw new InvalidArgumentException("La colonne `" . $key . "` doit être définie");
}
}
$bdd = new Connector();
$bdd->Insert("document", array("rang" => $options["rang"], "promo" => $options["promo"], "libelle" => $options["libelle"], "fichier" => $destination));
$document = $bdd->Select("*", "document", array("where" => array(array("fichier", "=", $destination))))[0];
return array("path" => $destination, "id" => $document["id"]);
}
示例2: addPromo
public static function addPromo($promo)
{
$bdd = new Connector();
$bdd->Insert("promo", array("id_promo" => $promo["id"], "libelle" => $promo["libelle"]));
}