pragma-framework / core Goto Github PK
View Code? Open in Web Editor NEWPragma Core Module for the Pragma Framework (ORM, Models, View, Controllers)
License: MIT License
Pragma Core Module for the Pragma Framework (ORM, Models, View, Controllers)
License: MIT License
We may encounter a problem with PDO & SQlite about locked database table.
See: http://blog.christosoft.de/2012/10/pdo-sqlite_table_locked_error/
And the upcoming commit: 7323e8e
Apparently, if a PDOStatement
is not completely consumed by calling fetch()
until there is no more results, or cleanly closed by 'closeCursor(), the table may stay in an unusable locked state.
I suspect the PDOStatement
destructor to properly close the cursor, so this may arise only with consecutive queries in the same script (Saw this error while doing unit tests).
The problem will only appear if the user/developer directly use the DB object, otherwise our QueryBuilder
and Model
abstraction would completely consume resultset (Maybe not with QueryBuilder::first()
though, I didn't checked yet).
Should we provide a way to cleanly close PDO cursor?
See:
Line 66 in cea4a12
Line 100 in cea4a12
According to https://secure.php.net/manual/en/language.oop5.late-static-bindings.php#language.oop5.late-static-bindings.self, self
in these contexts will be references to Model
class.
The returned result is correct (i.e: the class used to class these static methods) thanks to QueryBuilder::first() & QueryBuilder::get_objects() using new static
for objects instantiation, but IHMO, we should use static
for consistency's sake.
Is it possible to return object ($this) when use fonction save() from ORM/Model.php
Ex:
$obj = obj::build([])->save(); $obj->doSomething();
Maybe in merge() also ?
Model class should implement \JsonSerializable instead of SerializableInterface
While doing unit tests for QueryBuilder class, I realize I can not call the forge()
method on the bare object.
Trying something like this:
$qb = QueryBuilder::forge();
Ends up in constructor being called without argument, giving a inconsistent QueryBuilder object missing a proper $table attribute value.
Changing this class to be abstract would not allow to build dummy object not linked to any table, as it is the main purpose of the QueryBuilder.
By the way, calling forge()
with a class name as parameter may not completely solve this issue, the class name may be any existing class which may not be a valid children of QueryBuilder.
For this one, I suggest we use a is_subclass_of()
on the string parameter if any. For the former, declare the class as abstract should be enough.
I'm not sure how to make unit test for the QueryBuilder::subwhere()
, do you have some usage examples, please?
Lines 467 to 468 in c0e2168
The second part of the condition (!isset($hooks[$hook])
will always be true
as in the next line we only push hook in the array without using a specific index. So currently hooks can be duplicated in the same hooks array.
Should we consider this an error and fix using unique index for each hook?
Add the ability to put an alias on the table of the object
The goal is to avoid some users to test an API in order to find existings routes without credentials
Tried this tool against master: https://github.com/phpstan/phpstan
Gave me a little report we can have a look at:
$ phpstan -V
PHPStan - PHP Static Analysis Tool 0.9.2
$ phpstan analyse Pragma/ module.php routes/
18/18 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
------ ---------------------------------------------------------------
Line Pragma/ORM/Relation.php
------ ---------------------------------------------------------------
174 Access to an undefined property Pragma\ORM\Relation::$col_on.
182 Access to an undefined property Pragma\ORM\Relation::$col_to.
268 Function Exception not found.
------ ---------------------------------------------------------------
------ ------------------------------------------------------------------------------------------
Line Pragma/ORM/QueryBuilder.php
------ ------------------------------------------------------------------------------------------
157 Method Pragma\ORM\QueryBuilder::get_resultset() invoked with 2 parameters, 0-1 required.
------ ------------------------------------------------------------------------------------------
------ ---------------------------------------------------------------------------
Line Pragma/ORM/Model.php
------ ---------------------------------------------------------------------------
322 Call to static method generate() on an unknown class Webpatser\Uuid\Uuid.
333 Access to an undefined property Pragma\ORM\Model::$id.
351 Access to an undefined property Pragma\ORM\Model::$id.
------ ---------------------------------------------------------------------------
------ ------------------------------------------------------------------------------------------------------
Line Pragma/Router/Router.php
------ ------------------------------------------------------------------------------------------------------
136 Call to static method isEnabled() on an unknown class Pragma\Forms\CSRFTagsManager\CSRFTagsManager.
137 Call to static method getManager() on an unknown class Pragma\Forms\CSRFTagsManager\CSRFTagsManager.
282 Anonymous function has an unused use $callback.
294 Anonymous function has an unused use $callback.
------ ------------------------------------------------------------------------------------------------------
------ ----------------------------------------------------------------
Line Pragma/Router/RouterException.php
------ ----------------------------------------------------------------
25 Call to an undefined static method Exception::__constructor().
------ ----------------------------------------------------------------
------ -------------------------------------------------------------------------------------------------------------------------------------
Line Pragma/Helpers/Migrate.php
------ -------------------------------------------------------------------------------------------------------------------------------------
9 Parameter $event of method Pragma\Helpers\Migrate::postPackageInstall() has invalid typehint type Composer\Installer\PackageEvent.
18 Parameter $event of method Pragma\Helpers\Migrate::postPackageUpdate() has invalid typehint type Composer\Installer\PackageEvent.
27 Parameter $event of method Pragma\Helpers\Migrate::prePackageUninstall() has invalid typehint type Composer\Installer\PackageEvent.
56 Instantiated class Composer\Repository\InstalledFilesystemRepository not found.
56 Instantiated class Composer\Json\JsonFile not found.
------ -------------------------------------------------------------------------------------------------------------------------------------
------ -----------------------------------------------------------------------------------------------------------
Line Pragma/Controller/BaseController.php
------ -----------------------------------------------------------------------------------------------------------
24 Call to static method isEnabled() on an unknown class Pragma\Forms\CSRFTagsManager\CSRFTagsManager.
25 Access to constant CSRF_TAG_NAME on an unknown class Pragma\Forms\CSRFTagsManager\CSRFTagsManager.
27 Access to constant CSRF_TAG_NAME on an unknown class Pragma\Forms\CSRFTagsManager\CSRFTagsManager.
28 Access to constant CSRF_TAG_NAME on an unknown class Pragma\Forms\CSRFTagsManager\CSRFTagsManager.
29 Access to constant CSRF_TAG_NAME on an unknown class Pragma\Forms\CSRFTagsManager\CSRFTagsManager.
32 Call to static method getManager() on an unknown class Pragma\Forms\CSRFTagsManager\CSRFTagsManager.
36 Instantiated class Pragma\Forms\CSRFTagsManager\CSRFTagsException not found.
36 Access to constant TAG_REQUESTED_MESS on an unknown class Pragma\Forms\CSRFTagsManager\CSRFTagsException.
36 Access to constant TAG_REQUESTED on an unknown class Pragma\Forms\CSRFTagsManager\CSRFTagsException.
------ -----------------------------------------------------------------------------------------------------------
------ ----------------------------------------------------------------------------------------------------------------------
Line module.php
------ ----------------------------------------------------------------------------------------------------------------------
Class Pragma\Core\Module was not found while trying to analyse it - autoloading is probably not configured properly.
------ ----------------------------------------------------------------------------------------------------------------------
[ERROR] Found 27 errors
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.