Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

275
Views
Unable to open sqlite DB file from js axios.get request

Unable to open sqlite DB file from js axios.get request:(console.log outputs exception message). The request may call my PHP controller to select data from DB and return it json-encoded.

An another side, PHP contoller makes it's job good: screenshot

In this way i trying send an axios request from Vue form: screenshot or code:

Vue.createApp({
    data: () => ({
        processors:'',
        memory:'',
        drives:'',
        motherboards:'',
        cases:'',
    }),
    methods:{
        fetchProcessors:function (){
            axios.get('/src/controllers/getProcessors.php').then(
                (response) => {
                    this.processors = response.data;
                    console.log(response);
                });
        }
    },
    created:function (){
        console.log('vue is ok');
        this.fetchProcessors();
    }
}).mount(".js-form");

PHP controller code:

<?php

require_once __DIR__ . '/../../vendor/autoload.php';
use Doctrine\DBAL;

$connectionParams = [
    'url' => 'sqlite3:///db/calc_db.sqlite3'
];


try {
    $conn = DBAL\DriverManager::getConnection($connectionParams);
    $data = $conn->fetchAllAssociative('SELECT name, cost FROM processors');
    echo json_encode($data, JSON_THROW_ON_ERROR);
} catch (Exception $e) {
    echo $e->getMessage();
}

I've tryed to:

  • give chmod 777 to whole project
  • make request with phpstorm tools (returns same exception message)
  • send const json from controller - it wotks good, proofs that js request and php controller working together normaly, trouble is in connection to DB file (i think so)
  • use sqlite driver instead of sqlite3

full stack trace

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The problem was in 'path' param: i've launched my script from project root (working directory), so relative path to my DB builds correctly.

On web-server WD was a path, that i gave in request (controllers dir), so relative path to my DB builds incorrectly.

I've replaced path param like this and everything is OK:

$connectionParams = [
    'path' => dirname(__DIR__, 2) . '/db/calc_db.sqlite3',
    'driver' => 'pdo_sqlite'
];
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!