nystudio107 / craft-connect Goto Github PK
View Code? Open in Web Editor NEWAllows you to connect to external databases and perform db queries
License: MIT License
Allows you to connect to external databases and perform db queries
License: MIT License
Hi there,
absolute fan of your plugin. The only issue we are facing is with the encoding. It would be great if the charset could be defined in the connection. Now i have to convert it in Twig. For Example:
{%set overallComment = reviewVal.overallComment| raw | convert_encoding('UTF-8', 'ISO-8859-1')%}
What is the best practice (code) of connecting via a module I built in Craft using PHP?
Hi,
I am trying to use connect plug to connect to Microsoft SQL Server DB which resides on a different server than my web server. After the setup when I am using open() to open the connection and then using the isActive method and it is returning 0. Looks like it is not connected to the DB as my SQL query is not returing the expected result as well.
Please guide me what I am doing wrong. Any help is higly appreciated. Below is my .env and config file setting.
putenv("REMOTE_DB_DRIVER=sqlsrv");
putenv("REMOTE_DB_SERVER=xxxx");
putenv("REMOTE_DB_USER=xxxx");
putenv("REMOTE_DB_PASSWORD=xxxx");
putenv("REMOTE_DB_DATABASE=xxxx");
putenv("REMOTE_DB_PORT=1433");
//sql server db
'remote' => [
'driver' => getenv('REMOTE_DB_DRIVER'),
'server' => getenv('REMOTE_DB_SERVER'),
'user' => getenv('REMOTE_DB_USER'),
'password' => getenv('REMOTE_DB_PASSWORD'),
'database' => getenv('REMOTE_DB_DATABASE'),
'port' => getenv('REMOTE_DB_PORT')
],
{% set db = craft.connect.open('remote') %}
{% if isActive %}
hello active
{% else %}
not active
{% endif %}
Part of the docs says that Connect should be able to talk to any database that Yii2 has support for, and links to a page where Yii2 says it supports MSSQL.
However the only viable options that seem to be taken by the REMOTE_DB_DRIVER config are 'mysql' and 'pgsql', attempting to use 'mssql' leaves a "Driver not found" error:
Database Exception – yii\db\Exception
could not find driver
↵
Caused by: PDOException
could not find driver
in /home/ubuntu/sites/gllm/7_website/craft/vendor/yiisoft/yii2/db/Connection.php at line 712
I've tried spelunking into the code but can't find anything obvious. I have found an old issue on Stack Overflow where it was recommended to run composer require yiisoft/yii2-mssql
but that is not an installable package anymore. Further, it seems as though it's been retired (attempting to find that on GitHub or Packagist forwards to a renamed Yii3 variant now) and that support ought to be built-in since Yii 2.1?
Hi.
First, thanks for this great plugin! However I seem to be unable to actually use the createCommand function. I'm trying to do a simple INSERT INTO but can't get it to work.
The error i'm receiving is the following: "Call to a member function getQueryBuilder() on string"
{% set db = craft.connect.open('remote') %}
{% set sql = 'INSERT INTO tblContact_Management (city, email, lang, lastname) VALUES (citytest, mailtest, nl, De La Phantoma)' %}
{% set projectResults = craft.connect.query(db)
.createCommand(sql)
%}
Here's my actual code for trying to insert something. I have no issues on retrieving data though.
Is there a way to add option to send data to remote mysql ..
write directly to remote mysql .. as we allready use it to read data from. but need to send data too.. on button click
On the plugin documentation repo, it says it's compatible with Craft CMS version 3.x.x, but when you go ahead and install the plugin, Craft CMS 4.x.x is required.
Steps to reproduce the behaviour:
The docs should have different composer commands for the compatible Craft CMS versions
First and foremost, great plugin! Works as expected and does what it's expected to do.
However I can't seem to figure out how to use operands in the while.
I've tried the following:
.where({'price':'250000'})
- works fine
.where({'price':'< 250000'})
- retrieves nothing
.where(['price' => '250000'])
- returns error (found this somewhere in the readme.md)
Cant seem to find any solution in the yii files either.
EDIT: found it.
.where('price <= 250000')
- the solution
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.