1
Ewaan
Re: query queryF
  • 2005/2/4 8:49

  • Ewaan

  • Just popping in

  • Posts: 4

  • Since: 2005/1/18


Thanks



2
Ewaan
query queryF
  • 2005/2/3 18:31

  • Ewaan

  • Just popping in

  • Posts: 4

  • Since: 2005/1/18


function queryF and query are both declared in /class/database/mysqldatabase.php.

The code suggests that:
query has no body and does nothing.
queryF executes a sql statement and returns MySQL resource.

I've created numerous subclasses for XoopsUser and am rewriting the XoopsUserHandler to manage the data access for all the subclasses. For function &get() I've had to use queryF() to retrieve the MySQL resource. For $getObjects I'v used query() and am returned the resource.

All the XOOPS core code that I've seen uses query() for database querying.

1.Why can query() be used to return resources?

2.Why in two very similar cases i.e. the rewritten &get() and &getObjects(), query() can be used for one but does not return anything in the other?


Please can somebody explain.

Cheers

Ewan



3
Ewaan
Re:uploader.php and Notice: Undefined index:
  • 2005/1/28 9:46

  • Ewaan

  • Just popping in

  • Posts: 4

  • Since: 2005/1/18


If you have multiple images loop through $_POST['xoops_upload_file'] array:

//upload media
include_once XOOPS_ROOT_PATH.'/class/uploader.php';
$allowed_mimetypes = array('image/gif', 'image/jpeg', 'audio/mpeg');
$maxfilesize = 50000000;
$maxfilewidth = 4000;
$maxfileheight = 3000;

$uploadDir = '/uploads';
print_r($_POST['xoops_upload_file']);
print " count : ".count($_POST['xoops_upload_file']);
$uploader = new XoopsMediaUploader(XOOPS_ROOT_PATH.$uploadDir, $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight);
if(isset($_POST['xoops_upload_file'][0]))
{
for($i=0;$i<count($_POST['xoops_upload_file']);$i++)
{
if($uploader->fetchMedia($_POST['xoops_upload_file'][$i]))
{
if (!$uploader->upload())
{
$errors[] = $uploader->getErrors();
}
else
{
$filename=$uploader->getSavedFileName() . '<br />';
$saved_path=$uploader->getSavedDestination();
$mediaType='';
$mediaType=$uploader->getMediaType();
$j=strpos($mediaType,'/');
$mediaType=substr($mediaType,++$j);
$file_path = XOOPS_ROOT_PATH.'/modules/myModule/media/';
$new_thumb_file=XOOPS_ROOT_PATH.$uploadDir.'/tmpT';
touch($new_thumb_file);
createThumbImage($saved_path,$new_thumb_file,$mediaType);
$name='uniqueName';
$s1=rename($new_thumb_file,$file_path.'thumbs/'.$name);
$new_large_file=XOOPS_ROOT_PATH.$uploadDir.'/tmpL';
touch($new_large_file);
createLargeImage($saved_path,$new_large_file,$mediaType);
$name='uniqueName';
$s2=rename($new_large_file,$file_path.'large/'.$name);

//delete orginal uploaded file
unlink($saved_pathh);
if(!$s1||!$s2)
{
//manage filesystem errors
}
}
}
else
{
//manage uploader errors
//$errors[] = $uploader->getErrors();
}
}
}



function createThumbImage($filename,&$new_file,$format)
{
// Set a maximum height and width
$width = 100;
$height = 100;

// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);
if($width && ($width_orig < $height_orig))
{
$width=($height / $height_orig) * $width_orig;
}
else
{
$height = ($width / $width_orig) * $height_orig;
}

// Resample

$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
if($format=='jpeg')imagejpeg($image_p,$new_file);
if($format=='gif')imagegif($image_p,$new_file);
}



4
Ewaan
Re:uploader.php and Notice: Undefined index:
  • 2005/1/18 23:16

  • Ewaan

  • Just popping in

  • Posts: 4

  • Since: 2005/1/18


The variable you need to pass to the function fetchMedia is

$_POST['xoops_upload_file'][0]

e.g.

$uploader->fetchMedia($_POST['xoops_upload_file'][0])


in the example given $_POST['xoops_upload_file'][0]==partnerlogo




TopTop



Login

Who's Online

148 user(s) are online (87 user(s) are browsing Support Forums)


Members: 0


Guests: 148


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits