I am using this code:
$queryBuilder
->add('select', 'd.type')
->add('from', 'Entities:TypeDetail d')
->add('where', 'IDENTITY(d.typeName) = ' . $typeName->getId())
->add('andWhere', 'd.dateValue > ' . $dates['start'])
->add('andWhere', 'd.dateValue < ' . $dates['end']);
But I get this error: Notice: Undefined index: andWhere in...
I figure "andWhere" is not the correct name to use, but everywhere I read online suggests it is. But that is using the form ->andWhere(), not using ->add() like I am.
What am I doing wrong? Thanks
Have you tried this? -
$queryBuilder
->add('select', 'd.type')
->add('from', 'Entities:TypeDetail d')
->add('where', $queryBuilder->expr()->andx(
$queryBuilder->expr()->eq('IDENTITY(d.typeName)', $typeName->getId()),
$queryBuilder->expr()->gt('d.dateValue', $dates['start']),
$queryBuilder->expr()->lt('d.dateValue', $dates['end'])
));
Links here -
Doctrine Query Builder
Related
i want to query whereBetween two dates with time
here is code which is working fine
whereBetween('created_at', [now()->subDay()->format('Y-m-d') . ' ' . $tgame->start_time->format('H:i:s'), now()->format('Y-m-d') . ' ' . $tgame->end_time->format('H:i:s')]
but this code is not working
$date = Carbon::parse($request->date);
whereBetween('created_at', [$date->subDay()->format('Y-m-d') . ' ' . $tgame->start_time->format('H:i:s'), $date->format('Y-m-d') . ' ' . $tgame->end_time->format('H:i:s')]
please also explain thank you
Calling subDay() on the $date object will set the time in the Carbon object back 24 hours. So in the upper boundary for whereBetween, you are not using the request date, but the one 24 hours back.
To achieve what you want, you need to copy the object before changing it:
...->whereBetween('created_at', [$date->copy()->subDay()->format('Y-m-d') . ' ' . $tgame->start_time->format('H:i:s'), $date->format('Y-m-d') . ' ' . $tgame->end_time->format('H:i:s')]
Heei, I want to show data according to daterange. Specifically data on this day and 6 days to go. Here's my code now.
Controller
$hari = [];
for ($i=0; $i < 6; $i++)
{
$hari[] = date("Y M d") + $i;
}
$booking_room = jadwal_meeting::whereBetween('tanggal', [$hari, $hari + 6])->get();
return view('homepage')->with($booking_room);
Note: 'tanggal' is a field on table.
But I just get error like this
Unsupported operand types
: $booking_room = jadwal_meeting::whereBetween('tanggal', [$hari, $hari + 6])->get();
What's wrong with my code, anyone can help me please :)
Since $hari is an array, you have to use something like this:
$booking_room = jadwal_meeting::whereBetween('tanggal', [$hari[0], $hari[5]])->get();
Or more general:
$booking_room = jadwal_meeting::whereBetween('tanggal', [$hari[0], end($hari)])->get();
Try this code it will help you.
$from = '2018-04-12';
$to = date('Y-m-d', strtotime($from. ' + 6 days'));
$reservations = Reservation::whereBetween('tanggal', [$from, $to])
->get();
Thanks,
I'm new in Laravel please me.
I'm working on laravel project which is already done by other developers.
I am stuck in Model::with function.
QxAppDetail::with(['qx_app_translation', 'qx_app_pages.qx_page_translation',
'user_app_info' => function($query) use($device_registration_id) {
$query->where('device_registration_id', $device_registration_id);
}])->selectRaw($this->table . '.app_id, '
. 'if(qx_app_details.app_icon = "", "", CONCAT("' . $this->app_icon_path . '","/", qx_app_details.app_icon)) as app_icon, '
. 'if(qx_app_details.download_link="","",CONCAT("' . $apk_url . '",qx_app_details.download_link)) as download_link,'
. $this->table . '.open_link, qx_app_details.package_name, qx_app_details.qeexo_default_app, qx_app_details.service_id,qx_app_details.sort_order,qx_app_details.is_enabled')
->orderBy('qx_app_details.sort_order', 'ASC')
->whereIn('qx_app_details.device_registration_id', array(0, $device_registration_id))
->get();
in above query i need to concat url with column like
'if(qx_app_details.download_link="","",CONCAT("' . $apk_url . '",qx_app_details.download_link)) as download_link,'
in qx_app_pages. but i'm not able to do this.
qx_app_pages and qx_page_translation are tables
Current Query output is:
[{"app_id":472,"app_icon":"","download_link":"","open_link":"","package_name":"com.android.settings","qeexo_default_app":"0","service_id":"9","sort_order":"0","is_enabled":"1","qx_app_translation":[{"locale":"en_US","app_name":"Settings","app_description":""}],"qx_app_pages":[{"page_id":213,"page_icon":"iVBORw0KGgoAAAANSUhEUgAAAGYAAABmCAMAAAAOARRQAAAApVBMVEX\/\/\/80d+D09PQ1dNb+\/v79\n\/f319fX29vb8\/Pz5+fk1dNg0d94zduAsc98ncd8hb9\/w9f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H2qXomP7M1cumeQY1zYX6jn7XWszx34XKe\nOqroz9N4zV7fFxCXiXSGnizGMmbwm4FTfVPmVi55eXsXKSqw30SK38jnk1OjrZ8Ll5zkzaFW14ub\n36h7+s2f33OVS\/v9TeEfl2vt3lUuZr+RZkMavPzZF9I3K8z3STm5P210Dlo8+A3kBEIGcb15bX6V\nBclpq7JqXpS\/JrPFpgY4aDGG\/Mb8pHd6Wj7fNs3b29vH\/fK06XsZ4ZLEsN\/EsfysgsbC9Xr6JD2u\nVq+zWPQXFMPP07D1DSP+CkvkHicYg28lyG9HqW9LjcVoJL6iV\/XzQnzZXRji7q+U98k+Fav9aSrQ\nu3NIeXduNPbMcf\/rL31v8D+2OXl\/9El2FQAAAABJRU5ErkJggg==","action":"com.android.settings","app_id":"472","qeexo_default_page":"0","is_deleted":"0","qx_page_translation":[{"page_name":"Home","locale":"en_US"}]}],"user_app_info":{"order_id":391,"device_registration_id":"11862","app_id":"472","default_page_id":"213","sort_order":"0","qeexo_default_app":"1","is_enabled":"1"}}]
Thanks in advance.
This code worked good on ph 5.3. My server got upgraded to php5.6 and now the code no longer works.
Here is the two statements.
$sql = "UPDATE " . FORUM_TOUR_TABLE . "
SET page_subject = '$subject', page_text = '$message', page_access = $page_access
WHERE page_id = $id";
It says :
`SQL Error : 1064 Syntax error near 'WHERE page_id = 1' at line 3
UPDATE SET phpbb_forum_tour page_subject = ' Welcome To The Tower' , page_text = ' Update me please ' = WHERE page_access page_id = 1
Line : 172
File: admin_forum_tour.php`
That happens when I try to update a post.
When I try to add a new post using this code:
$sql = "INSERT INTO " . FORUM_TOUR_TABLE . " (page_id, page_subject, page_text, page_sort, bbcode_uid, page_access)
VALUES ($id, '$subject', '$message', $page, '$bbcode_uid', $page_access)";
This gives me this:
`SQL Error : 1064 Syntax error near ')' at line 2
INSERT INTO phpbb_forum_tour ( page_id , page_subject , page_text , page_sort , bbcode_uid , page_access ) VALUES (3, '2 Word Rule ', ' Hello World I am here ', 30 , ' f4e1be18dc ' )
Line : 198
File: admin_forum_tour.php`
I 100% apologize for asking this as I am more than sure it has been beat to death. I have been searching for a couple hours now and have all but given up. I had it working once but was told I opened my self up to injection. I am not a pro coder. I get lucky sometimes and make things work. I am sure these errors and code is basic to most but I am still learning.
Thanks for helping and understanding my "newbieness".
Is there a way to adjust the size of gorcery CRUD's list thumbnails?
The way it is now it's just silly big, and breaks the table flow.
If possible, it would be nice to have a PHP solution or grocery CRUD setting for this; if not - a CSS rule would be ok, I guess.
Same issue I came across, I'm sure it's a quick-and-dirty solution but it worked for me.
Open your application/library/Grocery_CRUD.php
Download timthumb from here
Place timthumb.php in Root directory (in same directory
level cache folder should be there)
Find function change_list_value
Find around line number 333 in Grocery_CRUD.php
$file_url_anchor .= 'class="image-thumbnail">';
Replace with... following
$file_url_anchor .= ' class="image-thumbnail"><img src="' . base_url('timthumb.php') . '?src=' . $file_url . '&w=100&h=100&zc=3' .'" height="50px">';
Again Find function get_upload_file_input
Find around line number 2545 in Grocery_CRUD.php
$input .= $is_image ? " $image_class'>" : "' target='_blank'>$value";
Replace with following
$input .= $is_image ? " $image_class'><img src='".base_url('timthumb.php') . '?src=' . $file_url . '&w=100&h=100&zc=3'."' height='50px'>" : "' target='_blank'>$value";
Hope this would help you to get rid of ugly size in your list as well as add/edit forms