brandonwamboldt / wp-orm Goto Github PK
View Code? Open in Web Editor NEW[Unmaintained] Light weight ORM for WordPress
License: MIT License
[Unmaintained] Light weight ORM for WordPress
License: MIT License
Line 100 in 17b8010
I think this line should be } elseif ($value instanceof BaseModel) {
because you want to call primary_key() as the flattened value in case a property is a type of object that is a subclass of BaseModel, and also because AbstractClass is undefined.
Also @brandonwamboldt, I saw this code being used in a plugin called uListing from a theme I purchased recently from StylemixThemes. Thought you should know.
// BaseModel.php
public function save() {
...
return $this->id;
}
Why do you return a raw "id" property ? You should return $this->{static::get_primary_key()}
at least in the Insert case.
All the examples are related to a simple table. What about tables with relationships.
E.g. An Organisation has many employees: So when I create a Organisation object at design time I will also have a array of employee set in the organisation object. Thus composing the employee object with the organisation object.
After doing that if I save organisation can i be assured that I will have a record in the organisation table and 1 or many employees in the employee table and their foreign keys set.
Please let me know.
get_table() and get_searchable_fields() is abstract static function. but it is deprecated php 5.2 or higher. I can see error message on wordpress admin console, when debug mode is on.
I try to fix it and modified BaseModel.php, Comment.php, User.php, Post.php as follows.
remove get_table() and get_searchable_fields() to BaseModelInterface,
interface BaseModelInterface {
/**
* Overwrite this in your concrete class. Returns the table name used to
* store models of this class.
*
* @return string
*/
public static function get_table();
/**
* Get an array of fields to search during a search query.
*
* @return array
*/
public static function get_searchable_fields();
}
and add "use WordPress\ORM\BaseModelInterface;" at heads of "Comment.php, User.php, Post.php". I also add "implements BaseModelInteface" to Comment, User, Post class definition as well.
I'm github/php newbie so just post solution here. I don't want break your module. Sorry for my bad English too.
It is currently impossible to do order by rand
, which can be useful in certain cases.
:)
Turning the query into a string would allow us to modify the query as is, and potentially modify the resultset.
Another option would be to allow us to add before/after filters to the query itself, that way we can just define methods to modify the actual query process.
Hello, i got PHP error
Parse error: syntax error, unexpected '[' in \wp-orm\lib\BaseModel.php on line 155
I use PHP 5.3 version.
How do we make our own tables on the backend using your class? All the other functionality/code is adequately documented, except this. In fact, I didn't even notice this folder (admin) until now. Could you provide some documentation and/or add it to the README?
Thanks for sharing your code, by the way. As a Wordpress developer myself, I'd like to make wp-orm part of my toolbox. It just needs a few more features and it'll be golden.
The construction of the OR clause for where_any is trimming one too many characters, thereby rendering the query invalid.
Query.php, line 477:
$where = substr($where, 0, -5) . ')';
should be
$where = substr($where, 0, -4) . ')';
Happy to submit a pull request.
I've just found this plugin and it looks really interesting, but it's not clear for me how to query Posts by some Custom Fields values.
For example, let's say I have a Custom Post Type "Exhibition" and I added 2 custom fields "start_datetime" and "end_datetime" (I added those using Advanced Custom Fields if that matters)
So, as an example, can you tell roughly how would look the query to get all the current Exhibitions?
(i.e., Exhibitions with "start_datetime" < now and "end_datetime" > now)
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.