phpthumb从数据库中的多个表访问图像
我能够毫无问题地从单个表中检索图像,但我不确定如果我在不同的表中有图像,它会如何工作。 假设我有两个可以包含图像的表(图像和类别)
images category
-gallery_id -cat_id
-image_id -image
-image
所以我想我可以在查询字符串中传递另一个参数来指定哪个表
if(mysql_escape_string(@$_GET['type']) === 'icon')
$PHPTHUMB_CONFIG['mysql_query'] = 'SELECT `image` FROM `category` WHERE (`cat_id` = \''.mysql_escape_string(@$_GET['id']).'\')';
else
$PHPTHUMB_CONFIG['mysql_query'] = 'SELECT `image` FROM `images` WHERE (`image_id` = \''.mysql_escape_string(@$_GET['id']).'\')';
这个工作正常
foreach($database->images->gallery_id($gal_id) as $v)
{
$img = "<img src=\"/test/include/phpThumb_1.7.9/phpThumb.php?w=150&id={$v->image_id}\" />";
echo "<li>{$img}</li>";
}
这会因“禁止参数:类型”而失败
echo "<img src=\"/test/include/phpThumb_1.7.9/phpThumb.php?w=150&type=icon&id={$database->category($v->cat_id)->cat_id}\" />";
我正在搜索代码但是没有看到任何设置“允许”参数的地方。
所以我的问题是: 这是从多个表获取图像的好方法吗?如果是,我如何允许“type”参数? 我想我可以将所有图像放在一张表中,但这对我来说似乎不是一个好主意......
ps 我在 phpthumb 支持论坛上发布了此内容,但没有得到任何回复,所以我在这里尝试。从那以后我就没有太多时间去研究它,希望这个周末我能抽出更多时间。
我正在使用 crdb 对于 $database 对象,如果有人想知道的话。
I am able to retrieve images from a single table without problem, but I'm not sure how it can work if I have images in different tables.
Say I have two tables (images and category) which can contain images
images category
-gallery_id -cat_id
-image_id -image
-image
So I figure I can pass another parameter in the query string to specify which table
if(mysql_escape_string(@$_GET['type']) === 'icon')
$PHPTHUMB_CONFIG['mysql_query'] = 'SELECT `image` FROM `category` WHERE (`cat_id` = \''.mysql_escape_string(@$_GET['id']).'\')';
else
$PHPTHUMB_CONFIG['mysql_query'] = 'SELECT `image` FROM `images` WHERE (`image_id` = \''.mysql_escape_string(@$_GET['id']).'\')';
This one works fine
foreach($database->images->gallery_id($gal_id) as $v)
{
$img = "<img src=\"/test/include/phpThumb_1.7.9/phpThumb.php?w=150&id={$v->image_id}\" />";
echo "<li>{$img}</li>";
}
This fails with 'Forbidden parameter: type'
echo "<img src=\"/test/include/phpThumb_1.7.9/phpThumb.php?w=150&type=icon&id={$database->category($v->cat_id)->cat_id}\" />";
I was searching through the code but don't see anywhere that sets which parameters are 'allowed'.
So my questions are:
Is this a good way to get images from multiple tables? If yes, how can I allow the 'type' parameter?
I guess I could just put all images in one table but it doesn't seem like a good idea to me...
ps
I posted this on the phpthumb support forum but didn't get any response, so I'm trying here. Haven't had much time to look into it since, hopefully I can make more time this weekend.
I'm using crdb for the $database object if anyone was wondering.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
妈的,我现在感觉很愚蠢,
在 phpThumb.php 中有(第 232 行) $allowedGETparameters 变量
不敢相信我错过了这一点,我必须检查除了那个文件之外的每个文件
Shit, I feel stupid now
in phpThumb.php there is (on line 232) the $allowedGETparameters variable
Can't believe I missed that, I must've checked every file except that one