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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:25:10+00:00 2026-05-25T21:25:10+00:00

I am creating an in-memory SQLite database and inserting some a row into it.

  • 0

I am creating an in-memory SQLite database and inserting some a row into it. Unfortunately, I am unable to select the row I just inserted.

<?php

const CACHE_SCHEMA = <<<EOD

CREATE TABLE test ( column1 TINYTEXT,
                    column2 MEDIUMTEXT,
                    column3 INT,
                    column4 INT )

EOD;

$db = new PDO('sqlite::memory:');

$statement = $db->query(CACHE_SCHEMA);
$statement->execute();

$statement = $db->prepare('INSERT INTO test (column1, column2, column3, column4) VALUES (?,?,?,?)');
$statement->execute(array('a', 'b', 123, 2));

$statement = $db->prepare('SELECT column2 FROM test WHERE column1 = ? AND column3 + column4 >= ?');
$statement->execute(array('a', 124));

var_dump($statement->fetch(PDO::FETCH_ASSOC));

?>

Output: bool(false)

As you can see, the 'SELECT' statement is not returning the row I inserted:

  • Adding 'column3' and 'column4' of the row I inserted yields 125.
  • The 'WHERE' clause of the statement becomes:

    'WHERE column1 = "a" AND column3 + column4 >= 124'

    once parameters are filled in.

  • Unless I’m mistaken, 125 >= 124.
  • 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-25T21:25:10+00:00Added an answer on May 25, 2026 at 9:25 pm

    It took a bit of thinking to figure this one out, but according to the documentation for PDOStatement::execute():

    “All values are treated as PDO::PARAM_STR.”

    So I need to change:

    $statement->execute(array('a', 124));
    

    to:

    $statement->bindValue(1, 'a');
    $statement->bindValue(2, 124, PDO::PARAM_INT);
    $statement->execute();
    

    …and then instead of binding a string value to the last parameter, it will bind an integer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some issues with producing an int matrix without creating memory leaks. I
I am creating a SQLite database. To get data from the table I am
Is it possible somehow to create in-memory database in SQLite and then destroy it
I like the idea of using an In-Memory Database such as SQLite when testing
What is the memory and performance usage compared to creating a object with only
Suppose that a process is creating a mutex in shared memory and locking it
JVM runs on FreeBSD with 18Gb memory. creating core file takes about hour, which
Creating a patch is very easy in SubVersion, With Tortoise, you right-click and select
I'v tried to solve a memory leak in the GLU callback by creating a
In a Java web application I am creating a zip file from various in-memory

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.