PHP Classes

nice work

Recommend this page to a friend!

      Simple Framework  >  All threads  >  nice work  >  (Un) Subscribe thread alerts  
Subject:nice work
Summary:connect database , load own library , some confused code
Date:2014-08-31 09:59:10


  1. nice work   Reply   Report abuse  
Picture of danidani danidani - 2014-08-31 09:59:10
hey bro
im using ur own framework its really light
but i have severeal question related to ur framweork to load own library from ur framework ? app does not connnect databse correctly how to connect database ?
im using sqlserv

3.what does this loop mean for in file System/Load.php?
foreach (get_object_vars($instance) as $_sl_key => $_sl_var)
if (!isset($this->buffer))

$this->$_sl_key =& $instance->$_sl_key;


btw overall its really nice and light framework
ur answer and feedback will be really helpfull

  2. Re: nice work   Reply   Report abuse  
Picture of Unay Santisteban Unay Santisteban - 2014-09-02 08:56:22 - In reply to message 1 from danidani
hi you there!

thanks for using my framework! :) ok, lets begin:

1. To load and use your own library you only have to put it in the "libraries" folder and add the name and folder in the "includes/autoload.php" file, for example:

$classes = array(
'Security' => 'libraries',
'Session' => 'libraries',
'Database' => 'libraries',
'Language' => 'libraries',
'Permission' => 'libraries',
'Integrity' => 'libraries',
'Input' => 'libraries',
'Upload' => 'libraries',
'Url' => 'libraries',
/** CUSTOM **/
'Customclass' => 'libraries', // Case Sensitive!!!

You can create a new folder with your custom classes, but by default the system load them from the libraries folder.

Then you can use you class calling it from any controller, model or view using the following sintax:

$this->customclass->custommethodclass(); //all in lowercase

2. You need to configure the database access in the "includes/dbconfig.php" file:

class Dbconfig {
public $driver = 'mysql'; // change this to mssql
public $dbhost = 'localhost';
public $dbuser = 'root';
public $dbpass = 'root';
public $dbname = 'test';
public $prefix = '';

only change the $driver property to the driver yo want, check this page:

3. Good, that piece of code allows to the app to user ALL of the libraries methods in the views, if you delete that code the libraries only were available in the models ands controllers.

I hope I've helped

PD: Sorry for my really bad english :(