Giter Site home page Giter Site logo

API issue: Connection#$encoding about ext-pq HOT 5 OPEN

m6w6 avatar m6w6 commented on August 15, 2024
API issue: Connection#$encoding

from ext-pq.

Comments (5)

m6w6 avatar m6w6 commented on August 15, 2024

Implementing this as property was probably a bad idea, so, should we add a method and deprecate the public property?

from ext-pq.

ParkFramework avatar ParkFramework commented on August 15, 2024

The ideal solution to implement lazy async connection :)

$db = new Connection($dsn); // new instance, not real connection to server

$db->encoding = 'UTF-8'; // if not or bad connect - save value, for deferred execute

yield from $db->exec($sql); // if not or bad connect - async connect and execute deferred query

I understand that it is very difficult, but it will be very convenient to use in userland.

from ext-pq.

m6w6 avatar m6w6 commented on August 15, 2024

If the main concern is setting the encoding for an async connection, it's probably best to use the client_encoding connection string parameter: http://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNECT-CLIENT-ENCODING

from ext-pq.

DaveRandom avatar DaveRandom commented on August 15, 2024

So I personally don't have any issues with a property assignment throwing. It's something other OO languages do all the time.

However, I will concede that it's not "the PHP way" and it would also be more of a BC issue than deprecating the property and replacing it with a pair of methods, so I'm happy to go with that. I'll check over the rest of the API for anything else that might present a similar problem.

from ext-pq.

m6w6 avatar m6w6 commented on August 15, 2024
  • Throw an exception on invalid property access
    (i.e. zend_replace_error_handling in php_pq_object_read_prop/php_pq_object_write_prop)
  • Deprecate all connection sensitive properties and introduce getters/setters with exceptions
  • Leave everything as it is now
    (i.e. E_NOTICE/E_WARNING/E_RECOVERABLE_ERROR (duh!))
  • Did I miss something?

from ext-pq.

Related Issues (20)

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.