예제 #1
0
        }
        return $this->db->lastInsertId();
    }
    /**
     *
     * @param type $estate_id 
     */
    private function insert_photos($estate_id)
    {
        $photos = array('53b7613ee067bfa5449fed2d9878a7c4.jpg', '5f99fec140c8745a459eee6355237405.jpg', '6e0a745bba6e38367980bede62643134.jpg', '6e6c71ac668da880f49dc067b41d4412.jpg', '6f3bae652b905c5813e8effe3272306b.jpg', '8c344b1de425fda0be3b81eb2bd76dec.jpg', '915fcd747d62579d89d5b42d76fdf423.jpg', '9978c9a01174104a19fb097024c27ddf.jpg', 'cbc4b2ae39fb3a02a3306a03a1ea901c.jpg', 'db5aa20fcb9811345dad08d9ad204845.jpg');
        $count = rand(1, 8);
        $q = $this->db->prepare("INSERT INTO `photos`\n            (\n                estate_id, preview, photo\n            )\n            VALUES\n            (\n                :estate_id, :preview, :photo\n            )");
        for ($i = 1; $i <= $count; $i++) {
            try {
                $photo = $this->rand($photos);
                $r = $q->execute(array(':estate_id' => $estate_id, ':preview' => 'mini_' . $photo, ':photo' => $photo));
            } catch (PDOException $e) {
                // @todo: dont scream be quite
                //throw new Exception( $e->getMessage() );
            }
        }
    }
}
try {
    $fix = new Fixture();
    $fix->connect('mysql:host=localhost;dbname=state', 'root', '900');
    $fix->fill(2000000);
    echo "\nOK.";
} catch (Exception $e) {
    die($e->getMessage());
}