本文整理汇总了PHP中Ad::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Ad::insert方法的具体用法?PHP Ad::insert怎么用?PHP Ad::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ad
的用法示例。
在下文中一共展示了Ad::insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: basename
}
// Allow certain file formats
if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
$message = "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
$message = $message . "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["imageToUpload"]["tmp_name"], $target_file)) {
$message = "The file " . basename($_FILES["imageToUpload"]["name"]) . " has been uploaded.";
//create ad and insert into database
$ad = new Ad(NULL, $user_id, Input::get('name'), Input::get('description'), Input::get('price'), $target_file, Input::get('location'), Input::get('zip'), Input::get('make'), Input::get('model'), Input::get('size'), Input::get('condition'));
$ad->insert();
$message = "You have successfully submitted your ad, with new image.";
$id = $ad->id;
} else {
$message = "Sorry, there was an error uploading your file.";
}
}
} else {
$ad = new Ad(Input::get('id'), $user_id, Input::get('name'), Input::get('description'), Input::get('price'), Input::get('image_url'), Input::get('location'), Input::get('zip'), Input::get('make'), Input::get('model'), Input::get('size'), Input::get('condition'));
$ad->update();
$message = "You have successfully updated your ad.";
$id = $ad->id;
}
} else {
$id = Input::get('id');
}