I have the following function:
public function findDate($empcode, $seldate, $hora) {
// query to select all user records
$query = "SELECT * FROM " . $this->table_name . "
WHERE cdempid = ? AND cddate = ? AND cdtime = ?";
// prepare query statement
$stmt = $this->conn->prepare($query);
// bind limit clause variables
/*$srch_date = "$fecha";
$srch_time = "$hora"; */
$stmt->bindParam(1, $empcode, PDO::PARAM_INT);
$stmt->bindParam(2, $seldate);
$stmt->bindParam(3, $hora);
// execute query
$stmt->execute();
// return row count
return $stmt;
And it is called from another program. This is the line that calls it:
$stmt = $citas->findDate($empcode, $seldate, $hora);
//$stmt = $citas->findDate($empcode, "20180329", $hora);
When I call it using the $ seldate variable, it does not find any records, but when I use the line that appears documented if it finds them. Now save the value that $ seldate brings and it is a correct date, which comes from a function in angular.
This is where you assign the value:
$data = json_decode(file_get_contents("php://input"));
$empcode = $data->empcode;
$seldate = $data->cddiacita;
This is the Angular function that calls the loadtime.php program, passing the date parameter that it takes from an angle type date input.
var app = angular.module ("myapp", []);
app.controller ("usercontroller", function ($ scope, $ http) {
$scope.loadEmployee = function(){
$http.get("loadEmp.php")
.success(function(data){
$scope.empleados = data;
});
};
$scope.loadService = function(){
$http.post("loadSrv.php", {'empcode':$scope.empleado})
.success(function(data){
$scope.servicios = data;
});
$http.post("loadTime.php", {'empcode':$scope.empleado, 'cddiacita':$scope.fecha.value})
.success(function(data){
$scope.horarios = data;
});
};
$scope.fecha = {
value: new Date(),
currentDate: new Date()
};
});
I already tried the bindParam usandp PDO :: PARAM_STR. Also use convert. I do not know why he is not taking it as a valid date. Any suggestions?