Welcome Guest, Not a member yet? Register   Sign In
Accessing a custom object with instanceof
#5

(This post was last modified: 01-26-2021, 06:29 PM by baxterheinen.)

The specific error is: Class 'LN_Account' not found

The model is like this:


PHP Code:
namespace App\Models;
use 
CodeIgniter\Model;
use 
App\Libraries\LN_Account;

Class 
AuthenticationModel extends Model {
    public function getAuthenticationCredentials($account) {
        if ($account instanceof LN_Account) {
            $sql "SELECT * FROM ln_authentication WHERE username = ?";
            $query $this->db->query($sql, array($credentials->username));
            $account $query->getCustomRowObject(0'LN_Account');
        }
        return $account;
    }


LN_Account is in app\Libraries

PHP Code:
namespace App\Libraries;

class 
LN_Account {
    ....


if I print_r $credentials inside the model/method I get this, so the controller knows what it is and created it. 

PHP Code:
App\Libraries\LN_Account Object
(
    [id] => 0
    
[username] => admin@domain.com
    
[password] => 
    [password_key] => 0
    
[password_key_timeout] => 0
    
[status] => 
    [created_at] => 0
    
[updated_at] => 0
    
[deleted_at] => 0


Okay so the outer if ($account instanceof LN_Account) seems to work now, it's this that doesn't:

$credentials = $query->getCustomRowObject(0, 'LN_Account')

Do I have to instantiate a new LN_Account() for it to use? I figured it would do it automatically.
Reply


Messages In This Thread
RE: Accessing a custom object with instanceof - by baxterheinen - 01-26-2021, 06:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB