示例#1
0
文件: test.php 项目: Gameonn/JS_API
$repeat_job = $_REQUEST['repeat_job'] ? $_REQUEST['repeat_job'] : 0;
$image = $_FILES['image'];
$date = date('Y-m-d');
$day_name = date("l", $user_date);
//if kid id is -1 then all kids for that user is assigned that job else only specified kid
$dy = json_decode($days);
// json decode of days array
$randomFileName = randomFileNameGenerator("Img_") . "." . end(explode(".", $image['name']));
if (@move_uploaded_file($image['tmp_name'], "../uploads/{$randomFileName}")) {
    $image_path = $randomFileName;
} else {
    $image_path = "";
}
//fetching all kids of that user
if ($kid[0] == -1) {
    $kid = DataClass::get_kids_by_user($uid);
}
foreach ($dy as $dayrow) {
    echo date('Y-m-d', strtotime($dayrow)) . '<br>';
}
die;
foreach ($kid as $row) {
    //adding jobs and related details
    $sql = "INSERT INTO `codebrew_jobstar`.`jobs` (`id`, `user_id`, `kid_id`,`image`, `title`, `description`, `generic`, `bonus_job`, `repeat_job`, `created_on`,`updated_on`) VALUES (DEFAULT, :user_id, :kid_id,:image,:title,:description, 0, :bonus_job,:repeat_job,NOW(),NOW())";
    $sth = $conn->prepare($sql);
    $sth->bindValue('title', $title);
    $sth->bindValue('description', $description);
    $sth->bindValue('bonus_job', $bonus_job);
    $sth->bindValue('repeat_job', $repeat_job);
    $sth->bindValue('image', $image_path);
    $sth->bindValue('user_id', $uid);