mysql - PHP use variable of class in other class -


i know php new classes-stuff. - love it. here problem:

i'm writing class stuff around account-managements. (e.g. create new account, account details, check if account exists .... ) within class need mysql-requests. therefor i'm using medoo-class (http://www.medoo.in).

class acc{  // attributes public static $account; public $pw; protected $error;  public function acc_exist() {     $database = new medoo();      $acc_count = $database->count("table_accounts", ["column_account" => acc::$account]);      if ($acc_count == 0)  {return true;} else {$this->error .= "account exists already!";}; }}; 

please note line:

$database = new medoo(); 

and

    $acc_count = $database->count("table_accounts", ["column_account" => acc::$account]); 

here bring in medoo. , ["column_account" => acc::$account] acctually works. read in other posts, made $accounts public static.

now call class this:

$my_acc = new acc(); $my_acc->account = 'luci'; $my_acc->acc_exist(); 

i need work that. doing acc($account) difficult in context of rest of code.

but expected, error:

strict standards: accessing static property acc::$account non static

clear static holds var's value. need other way. got idea?

best, lox

i don't think need have $account static, wouldn't make sense way you're going using code, try having public $account; , use ["column_account" => $this->account]

so:

class acc{  // attributes public $account; public $pw; protected $error;  public function acc_exist() {     $database = new medoo();      $acc_count = $database->count("table_accounts", ["column_account" => $this->account]);      if ($acc_count == 0)  {return true;} else {$this->error .= "account exists already!";}; }}; 

here's more information on how use static properly: static keyword in php


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -