Giter VIP home page Giter VIP logo

miner's Introduction

Justin Stayton

——— Indie Hacking

Lateral.run     Empower your customers to extend your app, not your feature backlog     Node.js Vue.js Tailwind CSS PostgreSQL AWS

——— Open Source

piratepx     Just a little analytics insight for your personal or indie project     Node.js Vue.js Tailwind CSS PostgreSQL 11ty

QueryQL     Filtering, sorting, and pagination for your Node.js REST API     Node.js

Suri     Your own link shortener that's easily deployed as a static site (for free)     11ty piratepx

miner's People

Contributors

detook avatar jstayton 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

miner's Issues

Not escaping field names / SQL injection

$pdo = new \PDO(/** .... */);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute( \PDO::ATTR_EMULATE_PREPARES, false );
$sql = new \Miner($pdo);
$sql->insert('logs');
$sql->set('foo-bar', 'foo-bar');
$sql->execute();

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-bar = ?' at line 1

silent failures

If you instantiate the \Miner class without supplying the optional PDO object, and then you call ->execute(), it currently just returns false.

This can cause code to fail in ways that are tricky to debug. It should probably throw an exception if you try to call ->execute() without first injecting the PDO dependency. Or at least it should call trigger_error(). I've fallen into this trap a few times.

Ability to do raw sql queries

First of all I want to say that your DB class works great!
But I have a small question. I miss the ability to do raw mysql queries. Is there a way to do this? I built it in by myself at the moment.

whereIn

When trying to use nested queries
in the function I removed the quote because it does not work with nested queries. Is there a way to override the automatic quoting?

I was thinking about adding an associative array with a override quote value but it looks like it would require a lot of rewriting of code

I have also added the ability to use WITH RECURSIVE in postgresql I'm not sure if that will be helpful for your code base, and I have certainly not made it complete. I can provide you with the code in the future if you are interested.

private function getCriteriaString

       case self::IN:
        case self::NOT_IN:
          if ($usePlaceholders) {
            $value = self::BRACKET_OPEN . substr(str_repeat('?, ', count($currentCriterion['value'])), 0, -2) .
                     self::BRACKET_CLOSE;

            $placeholderValues = array_merge($placeholderValues, $currentCriterion['value']);
          }
          else {
            $value = self::BRACKET_OPEN;

            foreach ($currentCriterion['value'] as $currentValue) {

             // $value .= $this->quote($currentValue) . ", "; <--  HERE
            $value .= $currentValue . ", "; <-- TO THIS
            }

            $value  = substr($value, 0, -2);
            $value .= self::BRACKET_CLOSE;
          }

          break;

Request Features

First time using github not sure if this is where to do it.

ADDED the ability to use ilike for non case sensitive comparison

/**
 * ILIKE comparison operator.
 */
const ILIKE = "ILIKE";

This update is so that limit and offset works with postgresql and it should work with mysql as well

public function getLimitString($includeText = true) {
  $limit = "";

  if (!$this->limit) {
    return $limit;
  }

  if ($this->limit['offset'] !== 0) {
    $limit .= $this->limit['offset'] . " OFFSET "; // <----- changed this from a , to a OFFSET statement to work with POSTGRESQL should work with MYSQL as well
  }

  $limit .= $this->limit['limit'];

  if ($includeText && $limit) {
    $limit = "LIMIT " . $limit;
  }

  return $limit;
}

group by

I believe that GROUP BY should not have ASC or DESC after it. ASC and DESC is after ORDER BY

Once again thank you so much for writing this code. It is awesome!

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.