just can't seem to get a result from a function called in its class...
require_once($_SERVER['DOCUMENT_ROOT']."/youradmin_v2/scripts/php/IPTC.php");
class Media{
function Media() { // connects to db } function getMetaData($mediaID){ global $select; $mediaDB = $select->mediaSelect($mediaID); $filePath=$mediaDB['filePath']; $itpc =new Image_IPTC($filePath); return $itpc->getTag($tag,0)." called?"; }
function newFileProcessing($file_name){ global $func;
global $select, $insert, $update;$mediaID=$insert->addMedia($file_name, $filetype, $filePathImg,$testI); $mediaDB = $select->mediaSelect($mediaID); $filePath=$_SERVER['DOCUMENT_ROOT'].$mediaDB['pathToFile']; $update-开发者_JAVA百科>updateQuery('media',"title='".$this->getMetaData($mediaID)."'");
}
} $media = new Media;
when i use $media->getMetaData($mediaID) on a php page it works? No errors and when its called in the class " called?" is added to the entry so i think its somink to do with the $itpc =new Image_IPTC($filePath) part which can be viewed here;
iptc class
can anyone see what i'm doing wrong?! any pointers appreciated.
best, dan.
$this->getMetaData($mediaID)
is not going to work in the function newFileProcessing($file_name) because it is not a member function of the Media class
if your code looked like this it should work
require_once($_SERVER['DOCUMENT_ROOT']."/youradmin_v2/scripts/php/IPTC.php");
class Media{
function Media() {
// connects to db
}
function getMetaData($mediaID){
global $select;
$mediaDB = $select->mediaSelect($mediaID);
$filePath=$mediaDB['filePath'];
$itpc =new Image_IPTC($filePath);
return $itpc->getTag($tag,0)." called?";
}
function newFileProcessing($file_name){
global $func;
global $select, $insert, $update;
$mediaID=$insert->addMedia($file_name, $filetype, $filePathImg,$testI);
$mediaDB = $select->mediaSelect($mediaID);
$filePath=$_SERVER['DOCUMENT_ROOT'].$mediaDB['pathToFile'];
$update->updateQuery('media',"title='".$this->getMetaData($mediaID)."'");
}
}
$media = new Media;
精彩评论