Answer the question
In order to leave comments, you need to log in
Bicycle "ORM" for automation. Should it continue and in what direction? Is it interesting?
A class for working with pdo has been created (for internal needs).
There is the following:
An abstract class for creating
SQL models query builder
Mini-caching of repeated queries within a connection (including checking for changed data).
Abstract Methods:
where():
where() - array
[
"user" => "10",
["%and", "status/!=|number" => "rhfghdfgh$%^456456"],
],
['%and',"date/>=" => "//now()//"
user = :user and status <> :status and (type = :type or type = :type1 or (st = :st or st = :st2)) and date >= now() or status = :status3
data:
( [ user] => 10 [status] => 456456 [type] => admin [type1] => advert [st] => 2 [st2] => 3 [
status3 ] => 1 ) a readable template for pdo (including parentheses, handling free requests like "now()" and filtering data) and an array with a list of keys and values for this template.
selectBy() - array
Example:
selectBy(array("count(*)","id"))
Result:
select count(*), id
Allows you to retrieve certain values from the database
+ grouping of results for easy unloading and working with several tables at the same time
selectBy(array("count(*) as count<-user","id<-user"))
Result:
Array (
[0] => stdClass Object
(
[user] => stdClass Object
(
[count] => 10
[id] => 17
)
)
)
Array (
[0] => stdClass Object
(
[user] => stdClass Object
(
[login] => Demo User
)
[group] => stdClass Object
(
[groupName] => VIP
[permissions] => {"createFlow":"1"}
)
)
)
Answer the question
In order to leave comments, you need to log in
Some brain-crushing syntax for where/select/order. What is the legacy of brainfuck?
I would be afraid to use this. The extra parenthesis is not there, and Messrs.
1 - Will it be useful to at least someone besides me?no, but for you it can be quite an acceptable tool if you hone it to a shine.
2 - In what direction to move and what are the jambs of this way of working with the base?your cant is that you write yourself without understanding what and call it all very big names, such as ORM
Model::data(array("status"=>2))->where(array("id"=>2))->update();
nobody needs them. because real queries are much more complex than selecting a single where clause. There are requests that simply cannot be put into builders. you focus on builders, but you should focus on ORM. Here's an example of a data mapper class . for its performance, a simple builder is used, but complex sql is written by hand. and almost always, not just objects are returned, but model objects associated with this data mapper. Note that almost every method callsreturn parent::result2objects(...);
return parent::findModelListByParams($params);
return parent::findModelByParams($params);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question