database-abstraction

php shared db connection ( design pattern help )

一个人想着一个人 提交于 2020-01-02 10:23:14
问题 I have a small php app that I want to build a layer of db abstraction on top of with a few "model" type classes. I'm using ezSQL_mysql to do the db work. My question is what is the best way to design the app? Should I use a singleton pattern to share the db connection? Should my "model" classes extend ezSQL_mysql ? Or maybe I'm totally off base here and need to do something else. What I need is something like this Controller.php $db = new ezSQL_mysql($db_user, $db_passwd, $db_database, $db

Protocol buffer Database abstraction framework

a 夏天 提交于 2019-12-24 07:46:19
问题 Has anyone heard of an enterprise grade database abstraction layer that builds on Google Protocol Buffers I can foresee such a DB tool set would have great possibilities from mobile computing all the way through to enterprise system development. 回答1: I reckon any key-value store (eg. Redis) will do? Maybe Riak would be a decent candidate as it provides a protobuf API. Eventually all you need to do is handle serialization and deserialization but that should be a rather thin layer on top of a

Advantages of using Doctrine for PHP?

两盒软妹~` 提交于 2019-12-21 04:05:06
问题 Just came across the Doctrine Project which has an Object Relational Mapper and a DB Abstraction Layer. What does Doctrine provide that other PHP abstraction layers don't? And what practical use can you put the ORM to, apart from fetching objects via queries written in Doctrine Query Language? Is the query language really something you want to develop an entire web app in? Does it perform well? On the whole does building an app on Doctrine make it easier to maintain and understand? Is it over

Counting the number of results returned by a database query in Codeigniter

帅比萌擦擦* 提交于 2019-12-19 07:49:11
问题 I am not having much luck detecting when a database query in Codeigniter returns zero results. I have had a good read of the notes on the PHP count function but am none the wiser! I call the query/view as follows from the controller: $data['result'] = $this->search_model->do_search(set_value('name')); $data['title'] = "Search results"; $this->load->view('search_view',$data); The view generates a results table for me OK, but when I try and trap an empty result, the count always returns 1: I

Counting the number of results returned by a database query in Codeigniter

旧街凉风 提交于 2019-12-19 07:49:01
问题 I am not having much luck detecting when a database query in Codeigniter returns zero results. I have had a good read of the notes on the PHP count function but am none the wiser! I call the query/view as follows from the controller: $data['result'] = $this->search_model->do_search(set_value('name')); $data['title'] = "Search results"; $this->load->view('search_view',$data); The view generates a results table for me OK, but when I try and trap an empty result, the count always returns 1: I

Pear DB class not found

淺唱寂寞╮ 提交于 2019-12-12 03:56:23
问题 I have create a class called Database.php for interacting with MySql database using Pear Db class. Database.php <?php require_once('DB.php'); require_once('cException.php'); class DataBase { private $dsn = 'mysql://root:xxxxxx@localhost/avatar'; private $conn; //Constructor function __construct() { global $conn; $this->conn = DB::connect($dsn); if(DB::isError($conn)) { throw new DatabaseConnectionException(); } } //destructor function __destruct() { $this->conn->disconnect(); } public

Is there a way of using PHP-ActiveRecord as symfony's ORM/abstraction layer?

岁酱吖の 提交于 2019-12-12 01:58:24
问题 I just discovered PHP-ActiveRecord not too long ago after struggling for nearly a month to write my own ORM (I'm hard headed like that) and I fell in love with it. I had looked at Doctrine and Propel before but decided to run away due to the sheer complexity and learning curve. With AR, I don't have the anxiety and learning difficulty I had with the others. Shortly thereafter, I also discovered the symfony framework (I was also trying to make my own framework from stratch after finding other

Prepared Statements in libdbi

二次信任 提交于 2019-12-10 16:25:33
问题 I want to use libdbi to make an application database-agnostic. I would like to use prepared statements. How can I use prepared statements with libdbi? All the examples I saw use normal select bla from blub where foo; statements and use escaping functions provided by libdbi for input escaping. If it is not possible to do this in libdbi, can you recommend another db-abstraction-library that can do that or explain why such a feature does not make sense? 回答1: Unfortunately, libdbi does NOT

php shared db connection ( design pattern help )

点点圈 提交于 2019-12-06 05:14:47
I have a small php app that I want to build a layer of db abstraction on top of with a few "model" type classes. I'm using ezSQL_mysql to do the db work. My question is what is the best way to design the app? Should I use a singleton pattern to share the db connection? Should my "model" classes extend ezSQL_mysql ? Or maybe I'm totally off base here and need to do something else. What I need is something like this Controller.php $db = new ezSQL_mysql($db_user, $db_passwd, $db_database, $db_host); $user = new User(); $user->update_email($new_email); $sale = new Sale(); $sale->purchase($amount);

What does “data abstraction” exactly mean?

隐身守侯 提交于 2019-12-04 08:29:56
问题 What does data abstraction refer to? Please provide real life examples alongwith. 回答1: Abstraction has two parts: Hide details that don't matter from a certain point of view Identify details that do matter from a certain point of view and consider items to be of the the same class if they possess those details. For example, if I am designing a program to deal with inventory, I would like to be able to find out how many items of a certain type the system has in stock. From the perspective of