FUNCTION database.AddDays does not exist - mysql

I'm trying to use dbfunction from EF6 on database MySQL but I get the follow exception "FUNCTION database.DiffDays does not exist".
I used this code:
var aux = bd.Atos.Where(w => w.IdAtivo == 1 && w.IdUtilizador == idUtilizador && DbFunctions.DiffDays(DbFunctions.AddDays(w.Data, w.NumDias).Value, DateTime.Now).Value < numeroDias)
What I'm missing?

Related

using a function from an outside script in love2d gives me an error

I'm making an action RPG in Love2d, and I moved all of my player code into a separate Lua script for the sake of organization - but now upon attempting to use player.load, I get this error:
Error
main.lua:22: attempt to index global 'player' (a boolean value)
Traceback
main.lua:22: in function 'load'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
this is my main.lua script:
-- RPG PROJECT IN LOVE2D
-- debug mode
debug = true -- SET FALSE BEFORE SHIPPING
-- ROOM CHART:
-- 0 - Title
-- 1 - Overworld
-- 2 - Shop
-- 3 - Boss Room
Room = 0
-- PLAYER STATE CHART:
-- 0 - free
-- 1 - attacking
-- 3 - can't move
function love.load(dt)
player = require 'Scripts/player'
player.load()
sti = require 'Libraries/sti'
gameMap = sti('Maps/overworld.lua')
menuImg = love.graphics.newImage('Assets/Menu.png')
love.window.setMode(800, 600)
end
function love.draw(dt)
if Room == 0 then
love.graphics.draw(menuImg, 0, 0)
end
if Room == 1 then
gameMap:draw()
player.draw()
end
if debug == true then
love.graphics.print("Current FPS: "..tostring(love.timer.getFPS( )), 10, 10)
end
end
function love.update(dt)
if Room == 0 then
if love.keyboard.isDown('space') then
Room = 1
end
end
if Room == 1 then
player.Update(dt)
if love.keyboard.isDown('escape') then
Room = 0
end
end
if love.keyboard.isDown('t') then
debug = not debug
end
end
and this is my player.lua script:
-- PLAYER SCRIPT
player = {x = 50, y = 50, speed = 3, state = 0, img = nil}
function player.load()
playerRight = love.graphics.newImage('Assets/playerRight.png')
playerLeft = love.graphics.newImage('Assets/playerLeft.png')
playerUp = love.graphics.newImage('Assets/playerUp.png')
playerDown = love.graphics.newImage('Assets/playerDown.png')
player.img = playerDown
end
function GetInput()
if player.state == 0 or player.state == 1 then
if love.keyboard.isDown('w') then
player.y = player.y - player.speed
player.img = playerUp
elseif love.keyboard.isDown('s') then
player.y = player.y + player.speed
player.img = playerDown
end
if love.keyboard.isDown('a') then
player.x = player.x - player.speed
player.img = playerLeft
elseif love.keyboard.isDown('d') then
player.x = player.x + player.speed
player.img = playerRight
end
end
end
function player.update(dt)
GetInput()
end
function player.draw()
love.graphics.draw(player.img, player.x, player.y)
end
Any help would be much appreciated!
Here's my folders as well, just in case it's a path issue:
UPDATE:
I solved it by renaming the player object to oPlayer, that was what was giving me an error.
I have severall Hints for you
Unclear
It looks you write it under Linux but should it also run under Windows?
If so, use OS independent folder delimiter ( the dot ) in require().
Example
player = require 'Scripts.player'
In General: Dont use Slash / Backslash \ in require()
Tip: LÖVE uses LuaJIT with modified Lua 5.1 check the Windows OS is easy
(For deciding to use Slash or Backslash (not in/for require()))
Clear
As #Luke100000 mentioned...
A Script for require has to return something.
If not than only a true wil be cached and a next require returns only true.
Therefore your player.lua content should be...
-- player.lua
local player = {x = 50, y = 50, speed = 3, state = 0, img = nil}
-- player.load() will be local
-- GetInput() wil be global
-- And the last line...
return(player)

LUA error : attempt to call method '' (a nil value)

I have some troubles with a simple code that I've made :
SWEP.PrintName = "Gestionnaire d'alarmes Administrateur"
SWEP.Author = "Frass"
SWEP.Instructions = "Clic Gauche : Ouvrir le gestionnaire"
SWEP.Spawnable = true
SWEP.AdminOnly = true
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = true
SWEP.Secondary.Ammo = "none"
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Slot = 1
SWEP.SlotPos = 2
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = true
SWEP.ViewModel = "models/weapons/v_pistol.mdl"
SWEP.WorldModel = "models/weapons/w_pistol.mdl"
local ShootSound = Sound( "buttons/button14.wav" )
function SWEP:PrimaryAttack()
self:TabletMenu()
end
function TabletMenu() (reduced, there's a lot of code inside)
When I try to use my SWEP in GMOD, the console give me this error :
[ERROR] lua/weapons/alarmtabletld.lua:44: attempt to call method 'TabletMenu' (a nil value)
1. unknown - lua/weapons/alarmtabletld.lua:44
I really don't understand what is doing this error...
Some help could be really nice !
You are calling a TabletMenu function that doesnt exist as part of the SWEP table. Is it defined somewhere else perhaps?

PhpStorm over-indenting multi-line functions

I'm currently attempting to configure PhpStorm to produce fully-PSR-2-compliant code, however its formatter is tripping up on long lines which contain functions with multiple parameters.
When I run the formatter, it converts this:
return ($thisIsALongLine || functionCall($arg1, $arg2));
into this:
return ($thisIsALongLine || functionCall(
$arg1,
$arg2
));
However, what I want is this:
return ($thisIsALongLine || functionCall(
$arg1,
$arg2
));
Does anyone know which formatter option tells it to further indent multi-line function calls in this instance?
Note: Usually, I'd format the above as this:
return ($thisIsALongLine
|| functionCall($arg1, $arg2));
However, that just bypasses the extra indentation issue, which I'd still need to fix for other situations.
Edit: This is the state of Wrapping and Braces, as requested by #LazyOne below:
Edit 2: Examples of two different types of line which PhpStorm's formatter isn't handling correctly. (Disclaimer: This is old code from a legacy system.)
Firstly, this:
if ($validateBudget && $this->getFinancialPeriodService()->validateBudget($formModel->action, $formModel->estimatedBudget, $formModel->startDate, $formModel->endDate, $formModel->isFirstPeriod)) {
becomes this:
if ($validateBudget && $this->getFinancialPeriodService()
->validateBudget($formModel->action, $formModel->estimatedBudget,
$formModel->startDate, $formModel->endDate, $formModel->isFirstPeriod)) {
when I would expect this based on the settings above:
if ($validateBudget && $this->getFinancialPeriodService()
->validateBudget(
$formModel->action,
$formModel->estimatedBudget,
$formModel->startDate,
$formModel->endDate,
$formModel->isFirstPeriod
)
) {
Secondly, if you enable alignment on chained methods, then this:
if ($evaluation->getExpert() != NULL && ($evaluation->getExpert()->getStatusId() == Evaluation::STATUS_ASSIGNED || $evaluation->getEvaluationStage() == Evaluation::STAGE_PROPOSED && CoreDateUtils::dateIsPast($proposal->getCalendar()->getStage1StartDate()) == false || $evaluation->getEvaluationStage() == Evaluation::STAGE_IN_PROGRESS && CoreDateUtils::dateIsPast($proposal->getCalendar()->getStage2StartDate()) == false)) {
is reformatted to this:
if ($evaluation->getExpert() != null && ($evaluation->getExpert()
->getStatusId() == Evaluation::STATUS_ASSIGNED || $evaluation->getEvaluationStage() == Evaluation::STAGE_PROPOSED && CoreDateUtils::dateIsPast($proposal->getCalendar()
->getStage1StartDate()) == false || $evaluation->getEvaluationStage() == Evaluation::STAGE_IN_PROGRESS && CoreDateUtils::dateIsPast($proposal->getCalendar()
->getStage2StartDate()) == false)) {
when I would expect this:
if ($evaluation->getExpert() != null
&& ($evaluation->getExpert()->getStatusId() == Evaluation::STATUS_ASSIGNED
|| $evaluation->getEvaluationStage() == Evaluation::STAGE_PROPOSED
&& CoreDateUtils::dateIsPast($proposal->getCalendar()->getStage1StartDate()) == false
|| $evaluation->getEvaluationStage() == Evaluation::STAGE_IN_PROGRESS
&& CoreDateUtils::dateIsPast($proposal->getCalendar()->getStage2StartDate()) == false)
) {
To be honest, at this point I suspect a bug in the formatter, so will open a ticket with JetBrains, however I'll leave this open in case anyone does know why it over-/underformats things.

Unable to send data to FPDF

I have a php page called page2.php which is connected to database via conectionDB.php and uploadChannel1.php to upload images. I have html page channel1.html where my form is.
But I need to send the input to FPDF to print it or save it, but this error keeps showing
Fatal error: Uncaught exception 'Exception' with message 'FPDF error: Some data has already been output, can't send PDF file'
I used ob_start and ob_flush and ob_clean and others but still not working I know the problem is with my php code. Please guys help me in this one.
require 'connectionDB.php';
require 'channel1.html';
require 'uploadChannel1.php';
if(isset($_POST['stdName']) && isset($_POST['secondGrand'])&& isset($_POST['grandName']) && isset($_POST['fatherAName']) && isset($_POST['motherGrand']) && isset($_POST['motherFatherName']) && isset($_POST['motherName']) && isset($_POST['subjectNum']) && isset($_POST['TotalNum'])&& isset($_POST['Avg']) && isset($_POST['birthDate']) && isset($_POST['gender']) && isset($_POST['stdType'])&& isset($_POST['jobs']) && isset($_POST['city'])&& isset($_POST['phone'])&& isset($_POST['bookDate'])&& isset($_POST['bookNo']))
{
$student=sanitizeString($_POST['stdName']);
$grand2=sanitizeString($_POST['secondGrand']);
$grand1=sanitizeString($_POST['grandName']);
$father=sanitizeString($_POST['fatherAName']);
$motherGrand=sanitizeString($_POST['motherGrand']);
$motherFather=sanitizeString($_POST['motherFatherName']);
$mother=sanitizeString($_POST['motherName']);
$subNo= sanitizeString($_POST['subjectNum']);
$Total=sanitizeString($_POST['TotalNum']);
$avg=sanitizeString($_POST['Avg']);
$graduateDate=sanitizeString($_POST['graduateYear']);
$birth=sanitizeString($_POST['birthDate']);
$gender=sanitizeString($_POST['gender']);
$job=sanitizeString($_POST['jobs']);
$stdType=sanitizeString($_POST['stdType']);
$City=sanitizeString($_POST['city']);
$tel=sanitizeString($_POST['phone']);
$bookdate=sanitizeString($_POST['bookDate']);
$bookNum=sanitizeString($_POST['bookNo']);
if(!empty($student) &&!empty($grand2) &&!empty($grand1) &&!empty($father)&&!empty($motherGrand)&&!empty($motherFather)&&!empty($mother)&&!empty($subNo)&&!empty($Total)&&!empty($avg)&&!empty($graduateDate)&&!empty($birth)&&!empty($gender)&&!empty($stdType)&&!empty($City)&&!empty($tel) && !empty($bookdate) &&!empty($bookNum) &&!empty($job))
{
session_start();
$_SESSION['stdName] =$studen ;
}
.......

parsing facebook json in rails avoid error occurred while evaluating nil.[]

I am trying to parse a json returned from facebook.
Now my idea is to get as much as detailks as possible from the facebook json.
So I use like ( assume auth is parse json from facebook)
education_array = auth['extra']['user_hash']['education']
education_array.each do |edu|
puts edu['school']['name']
puts edu['type']
puts edu['year']['name']
end
Now the problem here is that some people might have added the school name but not the year.
so obviously
edu['year']['name']
will throw error telling "error occurred while evaluating nil.[]" .
How do I avoid this ?
one way which I thought was
puts edu['year']['name']||""
but this would still throw error in case 'year' itself doesn't exist . (it would avoid error in case 'name' isn't found )
I don't want the following solution :
check if auth['extra'] exists
then check if auth['extra']['user_hash'] exists
then check if auth['extra']['user_hash']['education'] exists
then check if auth['extra']['user_hash']['education']['year']['name']
and so on..
I don't think using exception handling is a good way.
Any good way ?
Thank you
Use the && operator to check for nils.
education_array.each do |edu|
puts edu['school'] && edu['school']['name']
puts edu['type']
puts edu['year'] && edu['year']['name']
end
By way of example:
edu = { 'school' => { 'name' => 'value' } }
edu['school'] && edu['school']['name'] # => 'value'
edu = { 'school' => { } }
edu['school'] && edu['school']['name'] # => nil
edu = { 'school' => { } }
edu['school'] && edu['school']['name'] # => nil