Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter TextMate - Smart Code Generator
#1

[eluser]Tyler Diaz[/eluser]
Hi everyone,

I created this handy script about year or two ago. Seeing as I still find myself using it till this day, I thought I may as well share it just incase it's useful to anyone else.

Before you check this out, there's a couple of requirements:
1. TextMate
2. CodeIgniter
3. MySQL Database (local one makes it a lot faster)

Click here to see the script

What is it? It is a TextMate Command written in PHP.
What does it do? It helps you generate chunks of code by loading your database and generating "smart" code.
Awesome, how do I get started? You copy paste the Gist Link into a TextMate command. Like this: Screenshot *Place it in any bundle you have, inside a CodeIgniter or PHP one is ideal*

All done? So far so good. Now, you'll have to edit the script a bit according to your database. Near the beggining of the script, you'll see:
Code:
$db_connection_favorites = array(
        'default' => array(
            'host'         => '127.0.0.1',
            'user'         => 'root',
            'password'     => 'root',
            'db'         => 'database_name'
        ),
    );

The edit the 'db' row to the database you want to use. i.e: "phpbb, wordpress, drupal, farm_project", make sure the database is on your local computer if you're just changing the 'db' field in that array! Otherwise, you'll have to remotely connect to the database, which might be a bit challanging for begginers.

Alright, let's go through this quick checklist to make sure you got everything going good:
1. Copy and pasted the script to a TextMate command in any bundle. *You can give it any shortcut you want, but I found it quick and easy to use the Control+ALT+Command+Enter one you see in my screenshot*
2. Configured the database settings
3. Turned on your local MySQL

Alright, here comes that magic you were probably waiting for…

Thankfully, using it is easier than it is to setup. (:

So, let's suppose your database is called database_name
with a table called users.

Simply type in:
Code:
respond/array database_name users
and hit the shortcut keys. *Control+ALT+Command+Enter if you copied the screenshot* and the magic happens.

Did you see it? It just generated an array of your database!

Alright, let's take this a step a little further.

Now type in:
Code:
respond/insert database_name users

The script is smart enough to do any hacks it needs to on the MySQL Timestamps and stuff, and integers won't have any quotes around them, since they don't need them.

Here are some good combo's you can do:
Code:
respond/insert database_name users
Code:
respond/get database_name users
Code:
respond/update database_name users
Code:
respond/insert database_name users validation:all
Code:
respond/insert database_name users validation:username,user_id

Notes: The code is messy, so I'm sorry to anyone peeking through it looking to expand their work. The main parts of it were done in one night, and I just kept expanding on it, which caused it to become a mess.




Theme © iAndrew 2016 - Forum software by © MyBB