lithium

distinct selects in lithium

若如初见. 提交于 2019-12-21 06:27:27
问题 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'); 回答1: 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

How do I submit POST for cURL in Lithium

一笑奈何 提交于 2019-12-13 02:36:30
问题 I'm trying to create a custom Auth adapter for a legacy API. Let's call the adapter TR42 . Right now, I'm debugging TR42::check() so I'm using hardcoded values: <?php class TR42 extends \lithium\core\Object { public function __construct(array $config = []) { $defaults = [ 'scheme' => 'http', 'host' => 'localhost/tr42/mock_api_authenticate.php', 'action' => 'authLookup', 'fields' => ['username', 'password'], 'method' => 'POST' ]; parent::__construct($config + $defaults); } public function

PHP Fatal error: Class 'MongoDate' not found

泪湿孤枕 提交于 2019-12-10 17:43:54
问题 I use lithium console (lithium/console/li3) to run some command and I get this error: PHP Fatal error: Class 'MongoDate' not found My system details: mongodb server: 2.6.1 php mongodb client: 1.5.2 apache 2.4.7 php 5.5.9-1ubuntu4 $Requests = Requests::find('all', array('conditions'=>array( 'expired'=>array('<'=>new \MongoDate(time())), 'processed'=>0 ))); I don't have this error while running this code in older version system PHP Version 5.3.10-1ubuntu3.11 Apache/2.2.22 (Ubuntu) Server

Lithium Access Control

谁说胖子不能爱 提交于 2019-12-08 05:22:58
问题 I need to control who or what role gets access to what page or what method. Something like the class and method anotations on ASP MVC or Spring JAVA. How can I do this in lithium? 回答1: There is no built-in complete ACL functionality on Lihtium's core, beauce there is no really solution to ACLs problem. Hopefully, Lithium is kick-ass when it comes to deal with external libraries and plugin to extend the core functionality. Take a look to li3_access which is the most complete and flexible

Lithium Access Control

冷暖自知 提交于 2019-12-06 15:38:43
I need to control who or what role gets access to what page or what method. Something like the class and method anotations on ASP MVC or Spring JAVA. How can I do this in lithium? There is no built-in complete ACL functionality on Lihtium's core, beauce there is no really solution to ACLs problem. Hopefully, Lithium is kick-ass when it comes to deal with external libraries and plugin to extend the core functionality. Take a look to li3_access which is the most complete and flexible plugin or ACL out there, or simpler solutions . If your only need is to specify which actions are public and

Calling MySQL functions in Lithium

淺唱寂寞╮ 提交于 2019-12-06 08:59:44
问题 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. 回答1: 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' =>

Accessing more than one model deep relationships in Lithium

被刻印的时光 ゝ 提交于 2019-12-06 05:11:30
问题 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

Lithium apps that go beyond CRUD

佐手、 提交于 2019-12-06 00:39:10
问题 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

Custom lithium routing scenario

限于喜欢 提交于 2019-12-05 21:17:08
I've been tasked with rewriting an existing website with large pre-existing link catalog. For argument's sake, let's assume we can't do anything that would change the link catalog. Here's a few examples of the link structure we're working with: An item page would be: www.domain.com/widgets/some-totally-awesome-large-purple-widget A category sub page page would be: www.domain.com/widgets/purple-widgets A category parent page page would be: www.domain.com/widgets/ A custom page may be: www.domain.com/some-random-page The various page types are too numerous to write individual Routers for. Using

Lithium forward request

空扰寡人 提交于 2019-12-05 05:48:44
问题 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