Comments (4)
You will probably need to do a native query for that to work out, and not parameterizing that specific value. Just make absolutely sure that the string is on the correct format to avoid SQL vulnerabilities. E.g. through a regular expression such as:
/^x'[0-9a-f]{32}'$/
from doctrine-firebird-driver.
Finally, I found another way to use it by sending binary as parameter
I'm using https://github.com/ramsey/uuid-doctrine
from doctrine-firebird-driver.
I created a user defined function to use the x'' syntax. I don't use it anymore but maybe it could be usefull:
namespace Application\Doctrine;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\AST\InputParameter;
use Doctrine\ORM\Query\Lexer;
/**
* Class XExtension
* Usage in query: $qb->where('e.id = X(:id)')->setParameter('id', $value)
* @package Application\Doctrine
*/
class XExtension extends FunctionNode
{
/** @var InputParameter */
private $stringPrimary = null;
/**
* @param \Doctrine\ORM\Query\SqlWalker $sqlWalker
*
* @return string
* @throws \Doctrine\ORM\Query\AST\ASTException
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
$this->stringPrimary->dispatch($sqlWalker);
return "x'".$sqlWalker->getQuery()->getParameter($this->stringPrimary->name)->getValue()."'";
}
/**
* @param \Doctrine\ORM\Query\Parser $parser
*
* @return void
* @throws \Doctrine\ORM\Query\QueryException
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$lexer = $parser->getLexer();
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->stringPrimary = $parser->InputParameter();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
}
If you think it's a good idea, let me know and I'll make a PR. If not, close the ticket.
from doctrine-firebird-driver.
It seems to me that ramsey/uuid and ramsey/uuid-doctrine provide much of the answer and solution to your inquiry. You can convert the string to and from binary using hex2bin
and unpack
. For cohesion, you may even use \Ramsey\Uuid\Codec\StringCodec-> encodeBinary (...)
and \Ramsey\Uuid\Codec\StringCodec->decodeBytes(...)
.
Your second reply with the code snippet is nice, but it does not belong in this library. The goal with this library is to tackle only the absolute fundamentals of the DBAL.
from doctrine-firebird-driver.
Related Issues (11)
- Composer extension requirement HOT 2
- Problem on some serveur: General error: -303 Dynamic SQL Error SQL error code = -303 arithmetic exception, numeric overflow, or string truncation HOT 2
- Firebird v3.* support HOT 4
- pdo_firebird HOT 2
- Upgrading to latest doctrine version HOT 7
- Missing checkLastApiCall() HOT 3
- Dialect parameter HOT 2
- Error in transactions (update, insert) HOT 5
- Transaction + Generator HOT 7
- The driver is incompatible with PHP 7.4 HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from doctrine-firebird-driver.