Jump to content

Database class functionality


Liquid Fire

Recommended Posts

I have been building a framework for the pass 3-4 months and it is coming along pretty well.  I have a database class and this the functionality i currently have for it:

 

get_row() : return first row from passed query

get_one() : return first variable from passed query

get_column() : return first variable from all return as an array

get_all() : returns all data from all rows from passed query

insert() : field=>values array

delete() : delete records with the pass where statement

update() : field=>value array and where statement

table_exists() : searches for passed table name

row_exists() : searches for number of rows on a table with a where statement

table_information() : resturn DESCRIBE STATEMENT(MySQL) information

primary_key() : return field name of primary key

transaction() : query to run with transactions

commit_transactions() : commits transactions

rollback_transactions() : rollback transactions

get_indexes() : return all indexes for a table of database

get_relationships() : returns all foreign/primary key relationship for a table or database

get_tables() : return all table name for a database

truncate() : delete all record for passed table name

process query() : runs the query passed

add_index() : adds an index to a field

add_relationship() : add a relation to a table

 

is there any other functionality that i have not done that you think would be useful?

Link to comment
Share on other sites

I like how you can do

$select = $db->select()
            ->from(array('u' => 'users'))
            ->join(array('m' => 'messages'), 'u.user_id = m.user_id')
            ->where('u.user_id = ?', $userId)
            ->limit(5)
            ->order('m.message_created_at DESC');

if (!$ignoreDeleted) {
$select->where('is_deleted = 0');
}

$messages = $db->fetchAll($select);

with Zend_Db.

 

The above example could be for fetching the latest 5 messages of a user in whatever system you might have.

 

You could do something like that.

Link to comment
Share on other sites

  • 2 weeks later...

to cunoodle:

 

What are you looking for exactly? Are you just wanting to see some barebones code that helps demonstrate the MVC design pattern? Something that is not as bloated as Cake/CI, etc and that you would be able to tinker with yourself?

Link to comment
Share on other sites

I would like to see something like that dbo! I am trying to implement MVC but I just don't really know how to start. I have read in a few places that say that frameworks like cake and symphony break the mvc pattern. (don't ask me exactly how the break it, I just read they did)

Link to comment
Share on other sites

The code is coming together pretty well. I haven't added in all the bells and whistles yet, but its basically functioning. Let me get some documentation together and then I'll throw the code up.

 

Known requirements

-------------------------------------------------------

PHP5

PDO Support

mod_rewrite

 

Right now it basically includes this:

 

MVC Design Pattern

URL Segments/Smart URLS/SEO Friendly URLS... whatever you want to call them

Templating/Caching

Generic DB Abstraction

 

I'm planning on adding in some input validation, session management, and CRUD generation capability next.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.