Welcome Guest, Not a member yet? Register   Sign In
Pagination with query result
#1

Hello,
1- I have query like this:
select * from users where active=1 and state ='CA'  (simple query, but the my query more complex than this one)
I want to view list of all users with pagination with query result. on help file all see active record model
2-How I get single row with above query in CI ? without doing foreach ? like this below
Code:
$result = mysql_query("SELECT option_value FROM wp_10_options WHERE option_name='homepage' LIMIT 1");
$row = mysql_fetch_assoc($result);  
echo $row['option_value'];  (this is what I need )

Thank you
Reply
#2

PHP Code:
// Builder way
public function getOptionValue()
{
    $db      = \Config\Database::connect();
    $builder $db->table('users');

    $builder->select('option_value');
    $builder->from('wp_10_options');
    $builder->where('option_name''homepage');

    $query $builder->getRowArray();

    return $query;
}


// Standard Query With Single Result (Array version)
$query $db->query("SELECT option_value FROM wp_10_options WHERE option_name='homepage' LIMIT 1");
$row  $query->getRowArray();
echo 
$row
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

Thank you so much, I appreciate your time and help.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB