当前位置: 首页>>代码示例>>PHP>>正文


PHP Ad::insert方法代码示例

本文整理汇总了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');
}
开发者ID:wbreiding,项目名称:adlister,代码行数:31,代码来源:ads.edit.php


注:本文中的Ad::insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。