php - Fat Free: Using complex SQL queries -
Question: Is there an easy / safe way to run more complex SQL queries in fat-free framework. I have to use the solution PDO, but it is messy and ugly because I can not throw exceptions easily.
Background:
Axon class provides a database of fat free "secure" manipulation, but I want to do another complex query that can handle Xenan.
revealed the DB class, but I'll have to make queries to resort to "mysql_real_escape_string ()" which is not safe guarantee. So the highlighted PDO is being used.
The exposed PDO is the default error handling, which is a pain and results in ugly code.
$ pdo = F3 :: Received ('db') - & gt; PDO; $ Sql = 'Enter the configuration (config_name, config_value, comments) in the value (: config_name ,: config_value ,: config_comments) on the duplicate key update config_value =: config_value2'; If (! $ Stmt = $ pdo- & gt; Create ($ sql)) {$ errorInfo = $ pdo- & gt; ErrorInfo (); Trigger_error ('PDO error:'. $ Pdo-> Error code (). '' $ ErrorInfo [2]); Go out(); } $ Stmt- & gt; BindValue (': config_name', $ field, pdo :: PARAM_STR); $ Stmt- & gt; Bind value (': config_value', $ value, PDO :: param_st); $ Stmt- & gt; BindValue (': config_comments', $ Comments, PDO :: Param_st); $ Stmt- & gt; Bind value (': config_value2', $ value, PDO :: param_st); If ($ stmt-> Execute () === Incorrect) {$ errorInfo = $ stmt-> ErrorInfo (); Trigger_error ('PDO error:'. $ Stmt-> Error code (). ''. $ ErrorInfo [2]); Go out(); } So am I missing something? Can Axon handle more complex questions?
Have you seen the DB object and written questions about the parameters? You can make a little cleaner than directly messing with the PDO.
DB :: SQL ('Select * User ID where user =: UID', array (': UID' => array (F3 :: find ('POST.userID') ), PDO :: Paramatti)));
Comments
Post a Comment