GithubHelp home page GithubHelp logo

zoilomora / laravel-msaccess Goto Github PK

View Code? Open in Web Editor NEW
33.0 6.0 22.0 10 KB

Laravel ORM for Microsoft Access DB

Home Page: https://github.com/zoilomora/doctrine-dbal-msaccess

License: MIT License

PHP 100.00%
laravel orm microsoft-access

laravel-msaccess's Introduction

This repository is no longer maintained.

It is recommended to visit the updated repository https://github.com/zoilomora/doctrine-dbal-msaccess that is being maintained and is not limited to the Laravel framework.

Laravel ORM for Microsoft Access DB

Latest Stable Version Total Downloads Latest Unstable Version License composer.lock

This package helps you to manage Microsoft Access DB by ODBC Connection with the integrated Laravel ORM.

Installation

  1. Install via composer
composer require zoilomora/laravel-msaccess
  1. Add Service Provider to config/app.php in providers section:
\ZoiloMora\AccessServiceProvider::class,
  1. Create a DSN with the connection to the database.

  2. Add connection to config/database.php in connections section:

'access' => [
    'driver' => 'pdo_access',
    'connection_string' => 'dsn={namedsn}',
    'username' => '',
    'password' => '',
    'table_prefix' => '',
]
  1. Replace {namedsn} with the name of DSN.

Connect model with the connection

  1. In the model class add the $connection variable like this:
protected $connection = 'access';

License

Licensed under the MIT license

Read LICENSE for more information

laravel-msaccess's People

Contributors

zoilomora avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

laravel-msaccess's Issues

Numbers being Returned as Strings

It appears that any number fields are being returned as strings, so I can't use sum() in the query. Is there someplace I can add a PDO option to possibly change that?

Error SQLSTATE[] SQLDriverConnect: 0

Hola @zoilomora,

I use your package for my project, it's good because i can connect to the Access DB (finally >.<). But I don't know what happen, sometimes, when the user use the application, the Laravel error and show this message:

SQLSTATE[] SQLDriverConnect: 0

To fix this, i have to restart the Laragon (since I use it), but i guess there's something wrong, i don't know why. Maybe I do something wrong too, but i already check my code and nothing suspicious.

Do you know what happen?

Thank You.

Set charset to utf-8

Hi I'm having an error querying a table with columns names written in other language (french)

renaming of the column name is not an option so I tried to use the existing column names.

DB::select("SELECT * FROM Agenda_CHOKOUHI WHERE NuméroPatient = ?", [3]);

I tried adding the charset => utf-8 on the database config but to no avail.

'access' => [ 'driver' => 'pdo_access', 'connection_string' => 'FILEDSN=C:\Users\Adrian\Documents\Spelogic.dsn;Uid=admin;Pwd=;', 'username' => env('DB_USERNAME', 'forge'), 'password' => '', 'table_prefix' => '', 'charset' => 'utf8', ]

No Driver Found using PHP 7.2

Hola Zoilo,

I get error no driver found when using PHP 7.2.

Can you help us with that error?

Thank you, you package is amazing.

I keep getting "Couldn't parse SQL"

Hi, I liked your package, so far is the only one I've found that makes a .mdb to behave in a similar way to any other eloquent model, however I can't make it to work properly.

My environment would be the following

OS: Ubuntu 16.04
PHP: 7.2
Laravel: 5.6
Mysql: 8.0.16 (I need both MySQL and the .mdb)

the legacy .mdb file that the mdb viewer can open normally

I've follow the link (#2 (comment)) that explains how to correctly configure the odbc to work in linux, and I can confirm that it works correclty if a do a vanilla "select * from Workers", and in a way I could confirm that it works with your package, now, I say "In a way", because I had to manually disable the "[" and "]" that wraps the table names from "Illuminate\Database\Query\Grammar\Grammar" on every query that I run

class Grammar extends BaseGrammar{
...

    protected function compileFrom(Builder $query, $table)
    {
        // return 'from '.$this->wrapTable($table);
        return 'from '.$table;
    }
...
   protected function compileOrders(Builder $query, $orders)
    {
        // if (! empty($orders)) {
        //     return 'order by '.implode(', ', $this->compileOrdersToArray($query, $orders));
        // }

        return '';
    }
...
}

Otherwise I keep getting "Couldn't parse SQL", also by default it normaly adds an order clause "order by 1 asc" which I also disabled (shown above), disabling those makes a php like the following to work

return Worker::first();

which previously generated a query like this

select * from [Workers] order by 1 asc

so, how could I make it to work without all this ugly hacks that kind of messes up with my other normal database (mysql).

Thank you very much, for the package and for the help.

paging error

[2019-08-16 05:01:33] local.DEBUG: [27.02ms] select top 2 * from [dajg_base] order by 1 asc | GET: /
[2019-08-16 05:01:33] local.ERROR: SQLSTATE[42000]: Syntax error or access violation: -3100 [Microsoft][ODBC Microsoft Access ��������] ������ (��������ʧ) �ڲ�ѯ���ʽ 'row_number() over (order by 1 asc)' �С� (SQLExecute[-3100] at ext\pdo_odbc\odbc_stmt.c:258) (SQL: select * from (select top 2 *, row_number() over (order by 1 asc) as row_num from [dajg_base]) as temp_table where row_num between 3 and 4 order by row_num)

$results = \Illuminate\Support\Facades\DB::connection('access')->table('dajg_base')->offset($offset) ->limit($count) ->get();

Laravel 6.x

Do you have plans to support Laravel 6.x?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.