How to get single row data in CI

Result Rows

Row() returns a single result row data.  If query has more than one row, it returns only the first row of data. The result is returned as an object. Example:-

$query = $this->db->query(“YOUR QUERY”);

$row = $query->row();

if (isset($row))
{
echo $row->title;
echo $row->name;
}
If you want data in array format use row_array()
Example:

$query = $this->db->query(“YOUR QUERY”);

$row = $query->row_array();

if (isset($row))
{
echo $row[‘title’];
echo $row[‘name’];
echo $row[‘body’];
}

Generating Query Results as Row in CI

What is difference between result and result_array in CI

if we use result()  to get results it will returns  the query result as an array of objects
$query = $this->db->query(“YOUR QUERY”);

foreach ($query->result() as $row)
{
echo $row->title;
echo $row->name;
echo $row->body;
}

if we use result_array()  to get result as a pure array
$query = $this->db->query(“YOUR QUERY”);

foreach ($query->result_array() as $row)
{
echo $row[‘title’];
echo $row[‘name’];
echo $row[‘body’];
}

 
Generating Query Results in CI

How to check URL is valid or not in PHP?

URL validation in php

Sort Multi-dimensional Array by Value

Sort Multi-dimensional Array by Value
Above or PHP 5.3

Change or replace the href of an anchor tag with javascript

With help of java script you can change href of any anchor tag.

Why use Redis?

Redis is a key-value data store. It’s a “NoSQL” key-value data store. More precisely, it is a data structure server.

Not like MongoDB (which is a disk-based document store), though MongoDB could be used for similar key/value use cases.
The closest analog is probably to think of Redis as Memcached, but with built-in persistence (snapshotting or journaling to disk) and more datatypes.

Redis is a good if you want a highly scalable data store shared by multiple processes, multiple applications, or multiple servers. As just an inter-process communication mechanism it is tough to beat. Its speed also makes it great as a caching layer.

Below are some of the most common Redis use cases –
1. Session Cache
2. Full Page Cache (FPC)
3. Queues

Pros of Redis:
• It’s blazing fast
• it supports a wide variety of data types
• it’s open source and has an active community
• it’s simple to install and has no dependencies
• stores generic data types for any purpose
• easy to get started on a single cheap/free server

Cons of Redis:
• your dataset has to fit comfortably in memory
• no joins or query language
• you have to learn lua if you want something like stored procedures

The following link is superb to learn the basics of redis
http://try.redis.io/