cybernet Posted March 11, 2014 Share Posted March 11, 2014 so i found a pdo class to connect to mysql with pdo and looks easy to customize however i have an error that i can't figure it out class <?php class ApplicationResourcePool { static var $_dbHandle; // line 5 private static $_dbConfig = array( 'dsn' => 'mysql:dbname=vax', 'username' => 'vax', 'password' => 'veryrandpasswd', ); public static getDbHandle(){ if(self::$_dbHandle == null){ self::$_dbHandle = new PDO( self::$_dbConfig['dsn'] , self::$_dbConfig['username'], self::$_dbConfig['password'] ); } return self::$_dbHandle; } } class StockMapper { protected $_dbh; public __construct($dbh = null) { if($dbh == null){ $this->_dbh = ApplicationResourcePool::getDbHandle(); } else { $this->_dbh = $dbh; } } public getStockById($stockId){ $sth=$this->_dbh->prepare("SELECT * from stock WHERE id = :stockId"); $sth->bindParam(":stockId", $stockId); $sth->execute(); $result = $sth->fetch(PDO::FETCH_ASSOC); return $result[0]; } } $stockMapper = new StockMapper(); $stockData = $stockMapper->getStockById('302'); ?> Parse error: syntax error, unexpected 'var' (T_VAR), expecting variable (T_VARIABLE) in /path/index.php on line 5 i really don't know what to do Link to comment https://forums.phpfreaks.com/topic/286872-unexpected-t_var-expecting-variable-t_variable/ Share on other sites More sharing options...
jairathnem Posted March 11, 2014 Share Posted March 11, 2014 static variable. doesn't make sense, does it? Link to comment https://forums.phpfreaks.com/topic/286872-unexpected-t_var-expecting-variable-t_variable/#findComment-1472115 Share on other sites More sharing options...
cybernet Posted March 11, 2014 Author Share Posted March 11, 2014 please stop mocking me i presume it should be "private" instead of "static" ... right ? Link to comment https://forums.phpfreaks.com/topic/286872-unexpected-t_var-expecting-variable-t_variable/#findComment-1472116 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.