lithium

Calling MySQL functions in Lithium

我们两清 提交于 2019-12-04 14:08:57
How it's possible to call MySQL function (like GeomFromText() or SELECT AS ) in the Lithium Framework's CRUD? Using database->read() is to inconvenient (I often change the database columns) and including the function in the variable's value only ends up being escaped. Have you tried putting the function in the fields option? For example, I do this: Model::first(array( 'fields' => 'max(id)' )); To clarify, in your query, try this (i have not tested this): Model::first(array( 'fields' => array('field1 as myField', 'GeomFromText("POINT(x y)") as geom') )); 来源: https://stackoverflow.com/questions

Accessing more than one model deep relationships in Lithium

我是研究僧i 提交于 2019-12-04 09:38:13
Is it possible to access more than one model deep in a relationship in Lithium? For example, I have a User model: class Users extends \lithium\data\Model { public $validates = array(); public $belongsTo = array("City"); } and I have a City model: class Cities extends \lithium\data\Model { public $validates = array(); public $belongsTo = array("State"); } and a State model, and so on. If I'm querying for a User, with something similar to Users::first() , is it possible to get all the relationships included with the results? I know I can do Users::first(array('with' => 'City')) but I'd like to

Lithium apps that go beyond CRUD

♀尐吖头ヾ 提交于 2019-12-04 05:26:21
This is more or less a framework-centric version of a past Stack Overflow question , which is about how most introductory material on MVC applications tends to present a tight coupling between models, views, and controllers. For example, you'll have a User table that is modified by a User controller which in turn pushes filtered data to a User view. It's my impression that a lot of MVC frameworks tend to reflect this pattern as well. This is all fine and well for what it is, but it never really leads me to anything beyond building and displaying monotonous lists of things with an HTML form.

Lithium forward request

巧了我就是萌 提交于 2019-12-03 21:58:23
The controller redirect() method in Lithium does an actual HTTP redirect. But is there a method to simply forward a request to another controller/action without an HTTP redirect? For example, say I want to add an authentication layer and rather than redirecting the user to a "/auth/login" page, the login layout and template get rendered rather than the content for the page they requested. Then, when they submit the form and they authenticate, they're already on the page they requested. Zend framework has something similar with a _forward() method. Thanks! There's no method, mostly because you

distinct selects in lithium

房东的猫 提交于 2019-12-03 21:31:12
Using Lithiums Model, how do you achieve getting a distinct result set of specific fields from a collection in MongoDB? mongo query: db.blogs.distinct('url'); There currently isn't a way to do this elegantly to my knowledge. You can get results by working with the Pecl MongoDB object directly. The command function allows you to make any call you want. $db = Connections::get('default'); $blogs = $db->connection->command(array('distinct'=>'blogs', 'key'=>'url')); 来源: https://stackoverflow.com/questions/5750561/distinct-selects-in-lithium

lithium fill multiple models from view

心不动则不痛 提交于 2019-12-01 01:49:09
So lets say I have an Entities Model which is the base for a People and Organizations Model. I've three empty collections, one for Entities, one for People, one for Organization. Lets assume that the relationships between People and Organization will be ignored for the purpose of this question. Finally, I have a view, with fields for all three models. My question: Do I create a model class as a DTO (data transfer object) just to hold the data for all three models and save them to their respective collections in the controller? The DTO hierarchy would be like this: AddClientDTO Entity (with

lithium fill multiple models from view

断了今生、忘了曾经 提交于 2019-11-30 21:10:42
问题 So lets say I have an Entities Model which is the base for a People and Organizations Model. I've three empty collections, one for Entities, one for People, one for Organization. Lets assume that the relationships between People and Organization will be ignored for the purpose of this question. Finally, I have a view, with fields for all three models. My question: Do I create a model class as a DTO (data transfer object) just to hold the data for all three models and save them to their

How do I perform joins with lithium models?

情到浓时终转凉″ 提交于 2019-11-29 07:49:01
I read through lithium\data\model\query, but I didn't see any examples of joins. michaeltwofish There are multiple ways to perform a join with Lithium. Lithium will handle joins for you where you have defined relationships ( examples in the manual ). You can add joins to an existing Query object using the join() method (see the API )). You can pass an array of Query objects to finders using the key joins . You can pass the SQL directly to a connection using Connection->read() . The other methods are reasonably well documented, so I'll give an example of passing Query objects to a finder.

How do I perform joins with lithium models?

六眼飞鱼酱① 提交于 2019-11-28 01:28:35
问题 I read through lithium\data\model\query, but I didn't see any examples of joins. 回答1: There are multiple ways to perform a join with Lithium. Lithium will handle joins for you where you have defined relationships (examples in the manual). You can add joins to an existing Query object using the join() method (see the API )). You can pass an array of Query objects to finders using the key joins . You can pass the SQL directly to a connection using Connection->read() . The other methods are