CustomerRewardsRESTAPI/Model/ImageModel.php

67 lines
2.0 KiB
PHP
Raw Normal View History

2024-05-09 16:40:42 -05:00
<?php
require_once PD . "/Model/Database.php";
require_once PD . "/Model/ModelTraits.php";
2024-05-09 16:40:42 -05:00
/**
* Description of ImageModel
*
* @author Mike Howard
*
* Table: loyalty_value_blob
* Columns:
* loyalty_value_id bigint PK
* loyalty_member_id bigint
* loyalty_attribute_id bigint
* loyalty_value_mime_type varchar(255)
* loyalty_value_blob blob
2024-05-09 16:40:42 -05:00
*/
2024-05-09 16:40:42 -05:00
class ImageModel extends Database {
2024-05-09 20:25:56 -05:00
use ModelTraits;
2024-05-09 16:40:42 -05:00
public $memberId;
public $imageBlob;
2024-05-14 11:38:57 -05:00
public $uploadTo;
public $allowFileType;
public $fileName;
public $tempPath;
public $basename;
public $originalPath;
public $fileType;
function __construct() {
$this->uploadTo = PD . "\\public\\images\\";
//$this->uploadTo = PD . '/public/images/';
2024-05-14 11:38:57 -05:00
$this->allowFileType = array('jpg','png','jpeg','gif');
}
/* Process the uploaded image and store in database */
public function insertImage()
2024-05-09 16:40:42 -05:00
{
//$sql = "INSERT INTO ImageStore(ImageId,Image) VALUES('$this->image_id','" . mysql_escape_string(file_get_contents($tmp_image)) . "')";
//$fp=addslashes(file_get_contents($_FILES['image']['tmp_name'])); //will store the image to fp
//$query = "CALL insert_loyalty_member_image_proc('{$fileName}','{$fp}');";
2024-05-28 12:39:33 -05:00
/*
* $data = mysql_real_escape_string(fread(fopen($form_data, "r"), filesize($form_data)));
$result = mysql_query("INSERT INTO binary_data (description, bin_data, filename, filesize, filetype) ".
"VALUES ('$form_description', '$data', '$form_data_name', '$form_data_size', '$form_data_type')");
$id= mysql_insert_id();
*
* UPDATE t
SET blob_col=LOAD_FILE('/tmp/picture')
WHERE id=1;
*/
$query .= "CALL insert_loyalty_member_image_proc (" . $this->memberId . ", " . $this->imageBlob . ")";
2024-05-09 20:25:56 -05:00
//return var_dump($query);
$rowCount = $this->processImage($query);
return $rowCount;
2024-05-09 16:40:42 -05:00
}
}