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

  • Home
  • SEARCH
  • 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 am using PDO with PHP to create a new database and then a
<?php # Nettuts Tutorial using PHP Data Objects (PDO), /**This file contains the database
When using PHP PDO to access the database, is there a way to list
I'm using PHP PDO with PostgreSQL for a new project. Given the following function,
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
I'm using PDO to insert a record (mysql and php) $stmt->bindParam(':field1', $field1, PDO::PARAM_STR); $stmt->bindParam(':field2',
Using PHP, what's the fastest way to convert a string like this: 123 to
Using PHP, I can convert MySQL data or static table data to csv, Excel,

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.