Jump to content

macross

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Everything posted by macross

  1. Thanks call_user_func_array() works perfectly!
  2. I would like it to function like in codeigniter when passing Ids to methods you can do this: class Home extends Controller{ public function __construct(){ } public function index($id1, $id2){ echo $id1; echo $id2; } }
  3. So this is an example how i would like to get values from array inside a function. ( Note that array is an unknown size.. It might be empty or it might contain 3 keys) $data = array(1=>"hello", 2=>"welcome"); function doSomething($value1, $value2){ //Do something } doSomething($data) How can i achieve such thing?
  4. Thanks i will look into those books.
  5. Is there any decent eBook about building content management system from scratch which would use front-controller design pattern? Everything i find on the internet it's just plain old html/php smashup. I have searched and found only one book which is exactly what i wanted it's called "CMS Design Using PHP and jQuery", but as soon as i started reading it became clear that it's horrible (Bad programming practices)... Variable names starts with one letter like $j, $r directory names also with one letter, loops nested 4 levels up while you can achieve same thing with one loop... It's really hard to understand what’s happening when all I can see is spaghetti code. So maybe someone could point me to a decent eBook? I hope this is correct section for my question if not please move it.
  6. Solved my problem using implode() function.
  7. So i have an url routing class set up. I wan to call method via url so it would look something like this: http://www.mysite.com/index.php/Class/Method/Parameter. I was able to instantiate class like this: $controller = new $this->UrlPath[0]; But i can't call method the same way $controller->$this->UrlPath[1](); Is there a way to call method with an array?
  8. DreamerX i assume you know what is OOP, if thats the case, then check out this tutorial http://net.tutsplus.com/tutorials/php/create-your-first-tiny-mvc-boilerplate-with-php/
  9. Finally found out what was wrong so problem solved!
  10. So the correct way of calling a non static method would be $settings = $this->get_settings();? Because i get same error if i where using base::get_settings() or $this->get_settings();
  11. So i am currently coding database connection class and i have encountered very strange behavior from my script. base.class.php: <?php class base{ private $settings; function get_settings(){ $settings["dbhost"] = 'localhost'; $settings["dbuser"] = '*****'; $settings["dbpass"] = '*****'; $settings["dbname"] = 'core'; return $settings; } } ?> database.class.php <?php require_once 'base.class.php'; class database extends base{ private $query_now; private $link; public function __construct(){ $settings = base::get_settings(); $dbhost = $settings["dbhost"]; $dbuser = $settings["dbuser"]; $dbpass = $settings["dbpass"]; $dbname = $settings["dbname"]; $this->link = mysql_connect($dbhost, $dbname, $dbpass) or die ("Could not connect to the mysql database"); mysql_select_db($dbname, $this->link) or die ("Could not select the database"); } function query($query){ $this->query_now = $query; return mysql_query($query, $this->link); } function getArray($result){ return mysql_fetch_array($result); } } ?> When i try to create an instance of database class, i get mysql_connect error. I have tried to echo my array and it seems that correct information is being passed over. Now the strange thing is if i remove my password from the base class i don't get a mysql_connect error but this time instead i get "Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'core'@'localhost' (using password: YES) " In case you are wondering, does my mysql database user has a password, the answer is: yes for sure... (Also i have tried to setup a simple script for connecting to my database and everything worked fine) So any ideas?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.