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 6237207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:59:04+00:00 2026-05-24T10:59:04+00:00

I am using PHP PDO for work with database SQLITE3. Can somebody show me

  • 0

I am using PHP PDO for work with database SQLITE3. Can somebody show me how to put this commands in one transaction ?

            $db = new PDO('sqlite:/var/db/fan_coil.db');
            $sql = 'DELETE FROM fan_coil_plan WHERE fan_coil_id = :fan_coil_id;';
            $sth = $db->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
            $sth->execute(array(':fan_coil_id' => $fan_coil_id));

            $sql = ' DELETE FROM fan_coil_working_mode WHERE fan_coil_id = :fan_coil_id;';
            $sth = $db->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
            $sth->execute(array(':fan_coil_id' => $fan_coil_id));


            //****************** inserting working mode *************************************************************************************************


                $i = 0;
                $sql = 'INSERT INTO fan_coil_working_mode
                (fan_coil_id,working_mode, temperature_set_point, max_positive_temperature,min_positive_temperature,mode_type,max_fan_speed)
                VALUES(:fan_coil_id,:working_mode,:temperature_set_point,:max_positive_temperature,:min_positive_temperature,:mode_type,:max_fan_speed)';
                $sth = $db->prepare($sql);

            foreach ($modes as $key => $value) {
//file_put_contents('error.txt',$value['temperature_set_point'], FILE_APPEND );
                $working_mode = '0'; //treba da se izbaci ova kolona iz tabele
                $temperature_set_point = $value['temperature_set_point'];
                $max_positive_variation = $value['max_positive_variation'];
                $min_positive_variation = $value['min_positive_variation'];
                $max_fan_speed = $value['max_fan_speed'];
                $mode_type = ++$i;

                $sth->execute(array(':fan_coil_id' => $fan_coil_id, ':working_mode' => $working_mode, ':temperature_set_point' => $temperature_set_point, ':max_positive_temperature' => $max_positive_temperature, ':min_positive_temperature' => $min_positive_temperature, ':mode_type' => $mode_type, ':max_fan_speed' => $max_fan_speeed));
            }
  • 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-05-24T10:59:05+00:00Added an answer on May 24, 2026 at 10:59 am
    $db = new PDO('sqlite:/var/db/fan_coil.db');
    $db->beginTransaction();
    
    try {
        // your code
        $db->commit();
    }catch(PDOException $e) {
        $db->rollBack();
        throw $e;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two databases, one's MySql, one's MSSQL, I'm using php::pdo on both, except
How can I detect, using php, if the machine has oracle (oci8 and/or pdo_oci)
Possible Duplicate: PDO Prepared Statements I'm using the mysqli extension in PHP and I'm
Using PHP, what's the fastest way to convert a string like this: 123 to
I've been using PHP for too long, but I'm new to JavaScript integration in
I'm using PDO to access two SQLite 3 databases in PHP. I want to
I'm attempting to be more secure and start using PDO and prepared statements. This
Using PHP and MySQL, I have a forum system I'm trying to build. What
Been using PHP/MySQL for a little while now, and I'm wondering if there are
In using PHP's DOM classes (DOMNode, DOMEElement, etc) I have noticed that they possess

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.