Friday, May 20, 2016

Codeigniter insert, view, edit, delete and update

Codeigniter is one of the popular framework in php, here we are going to learn about complete basic functionality of codeignter like insert, view, edit, delete and update. This will help all the codeignter workers. with this functionality they manage codeignter and easy learn the functionality. Let see the steps and codes one by one.


STEP 1 :
First we want to download the codeignter complete framework file form codeignter site Click to Codeignter site. Download the codeignter file as .zip format and extract the files. Copy the above all files and create one folder in your WAMP www folder or XAMPP htdocs folder.

STEP 2 :
Then we have Open application->config->config.php file.There you can see
$config['base_url'] = '';

Test Laravel function

namespace Member;
use BaseController;
use View;
use Input;
use Paginator;
use Auth;
use LaraSnipp\Repo\Snippet\SnippetRepositoryInterface;

class UserController extends BaseController
{
    /**
     * Snippet repository
     *
     * @var \LaraSnipp\Repo\Snippet\SnippetRepositoryInterface
     */
    protected $snippet;

    public function __construct(SnippetRepositoryInterface $snippet)
    {
        $this->snippet = $snippet;
    }

    /**
     * Show dashboard with snippets and starred snippets of the current logged-in user
     * GET /members/dashboard
     */
    public function dashboard()
    {
        $page = Input::get('page', 1);

        // Candidate for config item
        $perPage = 10;

        $pagiData = $this->snippet->byAuthor(Auth::user()->slug, $page, $perPage, $all = true);
        $my_snippets = Paginator::make($pagiData->items, $pagiData->totalItems, $perPage);

        $user = Auth::user();
        $starred_snippets = $user->starred()->with('Snippet')->get();

        return View::make('member.users.dashboard', compact('my_snippets', 'starred_snippets'));
    }
}

Monday, February 1, 2016

after() / before()

Sometimes you want to insert something into the DOM, but you don't have any good hooks to do it with; append() or prepend() aren't going to cut it and you don't want to add an extra element or id. These two functions might be what you need. They allow you to insert elements into the DOM just before or after another element, so the new element is a sibling of the older one. 1 2 $('#child').after($('
')).text('This becomes a sibling of #child')); $('#child').before($('
')).text('Same here, but this is go about #child')); You can also do this if you're working primarily with the element you want to insert; just use the insertAfter() or insertBefore functions. 1 $('
I\'ll be a sibling of #child
').insertAfter($('#child'));

What is the differebce between using == and === ?


The == or != operator perform an automatic type conversion in Javascript if you want to compare between two values like this '10' == 10 , for this example we already know that 10 is number but '10' is not number it is string but when we compare that values one of them will convert to the same datatype we can say maybe '10' convert to number before compare, anyway we don't recommend to use this.
The === or !== operator will not perform any conversion mean it compares both value and datatype which could be faster than using == operator.
Example:[10] === 10 // is false[10] == 10 // is true'10' == 10 // is true'10' === 10 // is false [] == 0 // is true [] === 0 // is false '' == false // is true but true == "a" is false '' === false // is false