Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8213631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:11:08+00:00 2026-06-07T11:11:08+00:00

Question: Is there an easier /safer way of running more complex SQL queries in

  • 0

Question: Is there an easier /safer way of running more complex SQL queries in Fat Free Framework. The solution I have is to use PDO, but it’s messy and ugly as I can’t throw exceptions easily.

Background:

Fat Free provides the AXON class for “safe” manipulation of databases, but I want to do a more complex query that AXON can handle.

The DB class is exposed, but I would need to resort to “mysql_real_escape_string()” to build queries which is not guaranteed safe. So the solution appear to be using the exposed PDO.

The exposed PDO as default error handling, which is a pain and results in ugly code.

        $pdo = F3::get('DB')->pdo;
        $sql = 'INSERT INTO config(config_name, config_value, comments) VALUES( :config_name , :config_value , :config_comments)
                     ON DUPLICATE KEY UPDATE config_value= :config_value2';
        if (!$stmt = $pdo->prepare($sql)) {
            $errorInfo = $pdo->errorInfo();
            trigger_error('PDO Error: ' . $pdo->errorCode(). ' ' . $errorInfo[2]);
            exit();
        }

        $stmt->bindValue(':config_name', $field, PDO::PARAM_STR);
        $stmt->bindValue(':config_value', $value, PDO::PARAM_STR);
        $stmt->bindValue(':config_comments', $comments, PDO::PARAM_STR);
        $stmt->bindValue(':config_value2', $value, PDO::PARAM_STR);
        if ($stmt->execute() === false) {
            $errorInfo = $stmt->errorInfo();
            trigger_error('PDO Error: ' . $stmt->errorCode(). ' ' . $errorInfo[2]);
            exit();
        }

So is there something neater that I’m missing? Or can AXON handle more complex queries?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T11:11:10+00:00Added an answer on June 7, 2026 at 11:11 am

    Have you looked into the DB object and writing parameterized queries? You can view the docs here, and tab down to Parameterized Queries.

    It’s a little cleaner than messing directly with PDO.

    DB::sql(
        'SELECT * FROM users WHERE userID=:uID',
        array(':uid'=>array(F3::get('POST.userID'),PDO::PARAM_INT))
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In relation to my last question ( Is there an easier way of passing
Question: Is there a good free & open solution out there for revision control
I have a job interview tomorrow and I'm trying to answer this question: There
Question: Is there a way to load a lein plugin, say codex or lein-beanstalk,
Question Is there a way to define a method only once in C# (in
Question: Is there a way to check if a given font is one of
there's a question: Is there any way to pair Bluetooth device in Windows programmatically?
There are many articles in this site regarding my question. I have a matrix
I have seen this question: Are there any decent UI components for touch screen
Much like this question is there a way to make Visual Studio 2010 prompt

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.