Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9182121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:29:08+00:00 2026-06-17T18:29:08+00:00

Im using a select sql statement PDO fetchData, $user = ‘admin’; sql = ‘SELECT

  • 0

Im using a select sql statement PDO fetchData,

$user = 'admin';
sql = 'SELECT AccessPage FROM accessrights where UserName = '$user'';

in database the result would look like this:

-----------
Access Page
-----------
 - index

 + create

 - update

And I will store it inside a variable $result

How can I make the $result format to an array just like this?

$result = array('index','create','update');

Another question,

I used the codes in my function: but when I var_dump, it retun a array(0) { } value.

Here is my function:

    $user = CHtml::encode(Yii::app()->user->name);

    $connectionString[0] = Yii::app()->params['dbhandler2'];
    $dbhandler3 = new DBHandler($connectionString[0]);
    $dbhandler3->open();

    $dbhandler3->prepare("SELECT AccessPage FROM accessrights where UserName ='$user'");
    $dbhandler3->execute();
    $this->result2 = $dbhandler3->fetchAllData();
    $dbhandler3->close();

    $yourarrayname = array();
    while ($row = $dbhandler3->fetchAllData()) {
        $yourarrayname[] = $row['AccessPage'];
    }

    $this->access = $yourarrayname;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:29:09+00:00Added an answer on June 17, 2026 at 6:29 pm

    use the below code

     $user = 'admin';
     $sql = "SELECT AccessPage FROM accessrights where UserName = '$user'";
     $sth = $dbh->prepare($sql);
     $sth->execute();
    
     /* Fetch all of the values of the first column */
     $result = $sth->fetchAll(PDO::FETCH_COLUMN, 0);
     print_r($result); // the $result will be array  array('index','create','update');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following SQL statement: SELECT reply.id, reply.content, author.username FROM thread, reply, author
I can select using or with the sql statement select f.userid, f.friend_userid from friends
I am trying to retrieve some rows from the database using simple SELECT statement
I have a problem creating the following SQL Statement using LINQ & C# select
Using a SELECT statement in MS SQL 2005 TSQL, and no source table, just
How to select all columns from tables in join using linq Sql: select CTRL_RUN_JOB.*,
When using this SQL query: Select * from table_name what happens if the name
I have the code below: string SQL = select * from + TableName; using
For example using SQL I can do: SELECT (a+b) as c FROM table WHERE
I have a problem with a SQL statement: Using this select a.id as ID,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.