Closed sudnonk closed 6 years ago
You'd need to use PDO for this query, which Idiorm facilitates with the following method:
https://idiorm.readthedocs.io/en/latest/querying.html#getting-the-pdo-instance
I'd not be looking to add a feature for this or record this as a bug.
From: sudnonk notifications@github.com Sent: Tuesday, June 19, 2018 6:56:00 PM To: j4mie/idiorm Cc: Subscribed Subject: [j4mie/idiorm] Inserting a large object. (#341)
In normal PDO, we can bind a file pointer by using PDO::PARAM_LOB. But with idiorm, it does not work as I expected.
I tried like below.
<?php
$pdo = new PDO("mysql:host=localhost;dbname=" . DBNAME, USER, PASS);
$fp = fopen("test.txt", "r");
$stmt = $pdo->prepare("insert into test value (?,?)");
$stmt->bindValue(1, "by_pdo", PDO::PARAM_STR);
$stmt->bindValue(2, $fp, PDO::PARAM_LOB);
$stmt->execute();
$result = $pdo->query("select md5(file) as md5,file from test where id='by_pdo'")->fetch(PDO::FETCH_ASSOC);
require "idiorm.php";
ORM::configure(array(
'connection_string' => 'mysql:host=localhost;dbname=' . DBNAME,
'username' => USER,
'password' => PASS,
'caching' => true,
'caching_auto_clear' => true,
));
$test = ORM::for_table("test")->create();
$test->set("id", "by_idiorm");
$test->set("file", $fp);
$test->save();
fclose($fp);
$result = ORM::for_table("test")->select_expr("md5(file)", "md5")->select("file")
->where("id", "by_idiorm")->find_one();
echo "md5_pdo -> " . $result_pdo["md5"] . "\n"; //23cdc18507b52418db7740cbb5543e54
echo "md5_idiorm -> " . $result->get("md5") . "\n"; //7c422b25ccfed72b98891215bb6f4829
echo "raw_file -> " . file_get_contents("test.txt") . "\n"; //12345678
echo "raw_pdo -> " . $result_pdo["file"] . "\n"; //12345678
echo "raw_idiorm -> " . $result->get("file") . "\n"; //Resource id #6
I know that this project is already feature completed, but I think this is a bug. Or do I mistake something?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/j4mie/idiorm/issues/341, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAD-v0rmAUrpHrcSAVLaSRNLSpi95NJiks5t-LyggaJpZM4UtGk_.
I knew that method, but to process it as same as string
is better, isn't it?
Anyway, because you are saying so, I close this issue and pull request. Thank You.
In normal PDO, we can bind a file pointer by using
PDO::PARAM_LOB
. But with idiorm, it does not work as I expected.I tried like below.
I know that this project is already feature completed, but I think this is a bug. Or do I mistake something?