usmanhalalit / pixie

Database query builder for PHP, framework agnostic, lightweight and expressive.
MIT License
671 stars 179 forks source link

None. #171

Closed lordmemed closed 7 years ago

lordmemed commented 7 years ago

You're egoist.

eL-Prova commented 7 years ago

Hi,

Just copy the source. Then Create your DatabaseQuery class Creates the connection and stores in your DatabaseQuery in a field Set a Facade for your request of the query builder. Then create a query class or how you would like to call. And just create a method with the query in it.

So in pseudo

class DatabaseQuery {
    public function _construct()
    {
         //Create a PDO instance and put in the instance of the field

        //Create your alias like 
        class_alias('AliasFacade', "YourAlias");
        AliasFacade::setQueryBuilderInstance(new QueryBuilderHandler($this));
    }
}

class DataQueryClass
{
   public function GetUserById($id)
   {
       return YourAlias::table("table_name_users")->find((int)$id, "id");
   }
}
lordmemed commented 7 years ago

hai, @eL-Prova. thanks for your answer.

how about abstraction and extends from it? is there another example/pseudo-example maybe?

eL-Prova commented 7 years ago

Why you need an abstraction? The QueryBuilderHandler should be on his own. SOLID ;-) (Single responsibility) I think you need to try it with this and when needed create new ticket so your question will be more focused on your problem.

eL-Prova commented 7 years ago
  1. Where is $dbconf coming from? Constructor? Then you miss argument
  2. If you watch the source you see that $this->container is from the constructor which is Connection, that is $this not because it is DatabaseQuery. So new Connection should be put instead of the $this
lordmemed commented 7 years ago

@eL-Prova $dbconf is config array for pixie connection.

oh, i has solved that problem. thanks.

just more question.

  1. is it okay use join for many tables and select all row then fetch from it? will it slow it down? or using too much cpu resources?
  2. is pixie automatically shutdown a connection after we use it?

thank you very much.

sincerely, @lordmemed

Sent from my Polymer 2 using FastHub

usmanhalalit commented 7 years ago

@lordmemed this is not a place for homework discussion. Please continue elsewhere.