Welcome Guest, Not a member yet? Register   Sign In
Implementing Pear library in CI
#1

[eluser]bhakti.thakkar[/eluser]
hi all,
i have integrated PEAR in CI. i have placed the required file in application/libraries/Dbconnect.php myDB connection is mentioned in this file. and entire pear folder in application/ folder
in autoload file i have autoloaded:
$autoload['libraries'] = array('session','Pearloader','dbconnect');

All is working file
i am able to work with pear functions well. but the only thing of concern is in every controller or model, while interacting to DB, i need to do this:
$conn = & $this->dbconnect->connect();

for example :
class Agency_Model extends Model
{

function __Construct()
{
parent::Model();
}

function get_all_agencys()
{
$conn = & $this->dbconnect->connect();


$sql = "SELECT Agency_code from Maritime_Agency";
$rs = $this->Dbconnect->getAll($sql, DB_FETCHMODE_ASSOC);
return $rs;
}

}

why do i need to mention the connect() function every time? i have autoloaded the library. where am i going wrong?

Thanks
#2

[eluser]garymardell[/eluser]
I dont understand what the point is of using the dbconnect library. Whats wrong with codeigniters own implementation?
#3

[eluser]bhakti.thakkar[/eluser]
its because i m creating the application that can work with any DB and i dont want to keep changing my syntax accrdg to the DB selected (MYSQL MSSQL). Pear can take care of it
#4

[eluser]bretticus[/eluser]
[quote author="bhakti.thakkar" date="1252663643"]its because i m creating the application that can work with any DB and i dont want to keep changing my syntax accrdg to the DB selected (MYSQL MSSQL). Pear can take care of it[/quote]

Quote:Beyond simplicity, a major benefit to using the Active Record features is that it allows you to create database independent applications, since the query syntax is generated by each database adapter. It also allows for safer queries, since the values are escaped automatically by the system.
#5

[eluser]bhakti.thakkar[/eluser]
Still there are issuses with paginate with search in Codeigniter + MSSQL and pear can take care of it. Also excel issues that are pending in CI can be overcomed by using PEAR. the functions of PEAR (as per my exp) are far more easier to use than Active Record Class. OR may be i havent explored them as much.




Theme © iAndrew 2016 - Forum software by © MyBB