How to compare 2 'created_at' dates in Laravel 4.2 Mongodb - mongodb

In my application the user can view an image and click on the 'next' or 'previous' photo button. Currently, the logic for pulling the next / previous image urls is based on the 'created_at' field. I am trying to pick all documents from my collection where the 'created_at' date is greater than the current resource's (being viewed by the user) value. However, the first document that is returned has the same 'created_at' value as my current resource's 'created_at' field.
Eloquent Query:
$photos = Photo::where('_id', '!=', $this->_id)
->where('created_at', '>', $this->created_at)
->orderBy('created_at', 'ASC');
Using:
- Laravel 4.2
- Mongodb 2.6.10
- Library: jenssegers/mongodb 2.*
Any help will be much appreciated!
Thank you

i have one idea to your question....
1)add viewed_at column in photo table
2)onlcik function with update table value 'viewd_column' using date('Y-m-d H:i:s'); via ajax when user click image or next button
3)compare the created_at with viewed_at like below query
u need jquery onclick function here...for when user view the image that time the value stored in your table ..if u have created_at column...create another one column viewed_at now u can update that table column when user click that source image..then now u can get the click date from viewed_at column... now compare both date
$photos = Photo::where('_id', '!=', $this->_id)
->where('created_at', '>', $this->viewed_at)
->orderBy('created_at', 'ASC');
Its help to u.. thank u .. all the best.. if u have doubt ask to me.. i will help u..

Related

ChoronoForms v5 dropdown field dynamic preselection

My question is a very simple question:
I want to preselect the single data stored in a previous form in a dropdown field of a form (chronoforms v5).
In other words: In the previous form user has chosen 'New York' from a cities dropdown field.
Next time the user enters in the form he has to see the dropdown field positioned to the city of 'New York'.
Any suggestions?
Thanks a lot
Assuming that your users are registered and logged in them you can save the User ID and the selected value to a database table in the first form; then in the second form use a DB Read action in the On Load event to recover the saved value.

How to display schedule in struts2 framework?

I'm looking for help in my project in Struts2. I need to find a solution for displaying weekly schedule of classes. Project uses JDBC as well, values of each classes has to be saved in database. I was thinking of displaying classes in table like beneath, but i don't know how i can dynamically add values by clicking on hour from table.For any type of help, thank you.
Monday Tuesday Wednesday Thursday Friday
7.30-8.45
8.15-9.00
9.15-10.00
10.00-10.45
11.00-11.45
11.45-12.30
12.45-13.30
13.30-14.15
14.30-15.15
15.15-16.00
16.15-17.00
17.00-17.45
18.00-18.45
18.45-19.30
19.45-20.30
20.30-21.15
well, I had a project before which used Struts2 + Ibatis (now MyBatis) and it was handled as following, for sure, this is not the most efficient way to do it, but it can give you an approach, I was in 2nd level of the career when I implemented this:
For loading:
Create a table "Schedule" with "id", "startDate", "endDate" and "description" (optional)
Create a table "Courses" with "id", "name" and "scheduleId"
You save your "schedule" like: insert into schedule values (1, '07:40', '08:50', null);
Save a course this way: insert into course values('A1','Calculus 1', 1);
Then you just need to match them in the schedule using your custom "Action" like "LoadScheduleAction" by performing a query to db using jdbc.
If you want to mark the cell with the hour, for example (Monday, 9:40 - 10:50), then you can use "divs" and with javascript color them with blue or green, make sure you give each div and "id" so then you can get the cell you marked. Then, every time you click to select a cell or click to de-select a cell, I mean if you click the first time, then it gets colored, if you select for second time the same cell it returns to its original status and so on. Well, everytime you select a cell, you can save the coords in an array in session (or arraylist, or set) for example, session can contain: (Monday, 9:40 - 10:50), (Tuesday, 9:40 - 10:50) save it like a custom object inside an ArrayList in session:
ScheduleItem item = new ScheduleItem(day, hourRange);
Then, everytime you select a sell you get:
item1('monday', '9 - 10');
item2('monday, '11 -13');
item3('tuesday, '15-17');
and so on... all of them, saved into an arraylist temporary in your session.
ArrayList<ScheduleItem> scheduleItems = new ArrayList<ScheduleItem>();
scheduleItems.add(item1)
...
And finally when you already click on the button "submit" or something like that, just retrieve that list from session and persist it using jdbc in a new table like "studentSchedule" or "teacherSchedule" depending on what you need to do.
This is a very simple approach based on what I understood with your question. Hope it helps you someway.
Regards.

How to create a query with phpMoAdmin?

I just installed phpMoAdmin to manipulate my MongoDb collection but i can't find any tuto that show me how to use it
Any idea
ThankYou
You need to use PHP array syntax. Let's say you're looking for a field "name" and a value of "Smith". You need to type this into the "Query" box in phpMoAdmin:
array('name' => 'Smith')
You would then click on the "Query" button.
First you need to choose a database. After that, click 'Change database' button.
You will see all the collections. Or just add one. As soon as you select any of collections, you'll be able to see the list of possible actions. The last one in this list is 'query'.
I was looking for a way to search by id. The decision is:
hit link search (not query)
choose field _id
type (mongoid)your_id e.g. (mongoid)584179ee073be8d803865b0a
hit button search

How to set a look up field value to null/blank in access 2010?

I need some help with Access 2010 forms. My form has a number of fields (from one table). One of the field is a logical field. If the user selects true, then the next field (text field) should be enabled. This is working fine - I created an after update event procedure. The problem I have is if the user accidentally selects true, and then selects a value/s for the text field (the text field looks up a query - it is a look up field and it can have more than one value - the user can select/check as many from the list and they will be stored to the text field, separated by coma).
How will I set the text field (look up field) value to blank, if the user goes back and set the logical field to false? me.textfield.value = null gives an error.
Can anyone please help me? Thank you!
Just keep in mind that in fact a multi-value column is in fact a normalized data table.
So the display looks like this:
To clear the records selected in this child table, which is your mult-value selection, you can use this code behind the above button:
Dim rstChild As DAO.Recordset
Set rstChild = Me.Recordset.Color.value
Do While rstChild.EOF = False
rstChild.Delete
rstChild.MoveNext
Loop
Me.Color.Requery
An easy way to insert a blank lookup field is to select the field in design view and click on the lookup tab in the field properties. Before the first entry in Row Source insert the following " ";

ZendX Jquery Form Autocomplete

Hi i'm using zendx_jquery_form_autocomplete.
I have a mysql database with a table user. User has a ID and a Name.
My problem is that i don't know I can do my research in the Name column and have the id of the right row.
In the tutorial that i saw there is a research in a array and that work fine but now i shoul pass the id of my research...
Use mysql like operator for your search in rows.
$param = $this->_getParam('param'); //send from autocomplete
$result = Zend_Db_Table::getDefaultAdapter()->select()->from('users','user_id')->where('name like =?',"%$param")->query()->fetchAll();