I have a serious problem
I'm mounting a REST API with PHP. So, I have a controller called "Checkestablishment" (this will check the username and password from a database).
I have the next Query
SELECT table_users.ID, table_users.FirstName, table_users.LastName, table_users.ZIP, table_users.State, table_users.Country, table_users.Email, table_users.Birthday
FROM table_users, table_user_credentials
WHERE table_user_credentials.User = table_users.ID
AND table_user_credentials.Username = 'someuser'
AND table_user_credentials.Pass = 'somepass'
And it works fine, MySQL gets me the desired row.
But when i'm trying to execute it in PDO, I'm getting null.
This is my code
public function add()
{
global $counect;
$i = 0;
$Query_CheckCredential = "SELECT table_users.ID, table_users.FirstName, table_users.LastName, table_users.ZIP, table_users.State, table_users.Country, table_users.Email, table_users.Birthday
FROM table_users, table_user_credentials
WHERE table_user_credentials.User = table_users.ID
AND table_user_credentials.Username = ':Est_User'
AND table_user_credentials.Pass = ':Est_Pass'";
$PS_CheckCredential = $counect->prepare($Query_CheckCredential);
$Sucess = $PS_CheckCredential -> execute(array(
':Est_User'=>$this->str_User,
':Est_Pass'=>$this->str_Pass
));
if($Sucess)
{
$PS_CheckCredential -> bindColumn(1, $User_ID);
$PS_CheckCredential -> bindColumn(2, $User_FirstName);
$PS_CheckCredential -> bindColumn(3, $User_LastName);
$PS_CheckCredential -> bindColumn(4, $User_ZIP);
$PS_CheckCredential -> bindColumn(5, $User_State);
$PS_CheckCredential -> bindColumn(6, $User_Country);
$PS_CheckCredential -> bindColumn(7, $User_Email);
$PS_CheckCredential -> bindColumn(8, $User_Birthday);
//$PS_CheckCredential -> setFetchMode(PDO::FETCH_ASSOC);
$Array_Est_Keys = array('ID', 'FirstName', 'LastName', 'ZIP', 'State', 'Country', 'Email', 'Birthday');
$Array_Est_Keys = array_fill_keys($Array_Est_Keys, '');
do
{
$Array_User['ID'] = $row['ID'];
$Array_User['FirstName'] = $User_FirstName;
$Array_User['LastName'] = $User_LastName;
$Array_User['ZIP'] = $User_ZIP;
$Array_User['State'] = $User_State;
$Array_User['Country'] = $User_Country;
$Array_User['Email'] = $User_Email;
$Array_User['Birthday'] = $User_Birthday;
}
while($row = $PS_CheckCredential->fetch(PDO::FETCH_ASSOC));
if(empty($Array_User))
{
return false;
}
else
{
return $Array_User;
}
}
else
{
echo "No luck";
//return false;
}
I tried to fetch the query by different ways, but no one solved my problem.
P.D. Sucess marks me as true, because the execution of the query was successfully, but i'm getting null (i made a print_r() for the array that i'm creating and i'm getting all the array with values in null).
Thanks for your time. Cheers!