dongxiao0449 2017-08-13 19:30
浏览 9

too long

I've built a class that grabs data using cURL from imdb & allmusic and uploads it to a database. I'm having a problem with a method that inserts the data to my db, all the data gets inserted correctly, but when I use the copy() function the image doesn't get uploaded to the destination folder. If I use copy() in other methods or from outside my class the image gets placed in the destination folder. for example I have a method that will update the data and copy() works just fine. I'm pretty confused and probably missing something obvious.

public function insertData() {

    if ( !$this->tagExists() ) {

        // insert the data if the tag is new.
        $data = $this->sortData();

        switch (true) {
            case $this->is_imdb():

                $insertArray = [
                                "tag" => $this->imdb,
                                "title" => $this->cleanString( $data["title"] ),
                                "plot" => $this->cleanString( $data["plot"] ),
                                "director" => $this->cleanString( $data["director"] ),
                                "rating" => $this->cleanString( $data["rating"] ),
                                "metascore" => $this->cleanString( $data["metascore"] ),
                                "release_date" => $this->cleanString( $data["release_date"] ),
                                "cast" => $this->formatCast(),
                                "timestamp" => time()
                ];
                $poster = $data["poster"];
            break;
            case $this->is_allmusic():

                $insertArray = [
                                "tag" => $this->allmusic,
                                "artist" => $this->cleanString( $data["artist"] ),
                                "album" => $this->cleanString( $data["album"] ),
                                "overview" => $this->cleanString( $data["overview"] ),
                                "tracklist" => $this->formatTracklist(),
                                "rating" => $this->cleanString( $data["rating"] ),
                                "timestamp" => time()
                ];
                $poster = $data["cover"];
            break;
        }
        if ( !$this->imageExists() ) {

            copy( $poster, $this->var["imagePath"] );
        }

        //inserts the data into the database and returns true
        return $this->db->insert( $this->var["table"], $insertArray );

    } else {
        return false;
    }
}

this code doesn't work inside the method, but works elsewhere.

if ( !$this->imageExists() ) {

    copy( $poster, $this->var["imagePath"] );
}

the full class https://gist.github.com/anonymous/0ef3a8522e83185b552ff36eee1ee3c0

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 gg加速器加速游戏时,提示不是x86架构
    • ¥15 python按要求编写程序
    • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
    • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
    • ¥15 opencv图像处理,需要四个处理结果图
    • ¥15 无线移动边缘计算系统中的系统模型
    • ¥15 深度学习中的画图问题
    • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
    • ¥15 Python报错怎么解决
    • ¥15 simulink如何调用DLL文件