Code Monkey home page Code Monkey logo

Comments (6)

harikt avatar harikt commented on August 23, 2024

You mean PDO::FETCH_NUM ?

from aura.sql.

pmjones avatar pmjones commented on August 23, 2024

Not sure what you mean here @gholol -- can you expand a bit?

from aura.sql.

gholol avatar gholol commented on August 23, 2024

Well, sure guys.

Aura.Sql provides fetchAssoc() method.

We can use it like this

$result = $pdo->fetchAssoc($stm, $bind);

Now, this of course retrieves an ASSOCIATIVE array (where the key is the
first column, and the row arrays are keyed on the column names), and so, I cannot use it with list() function, because list() works only with numeric arrays.

I can do a workaround around this, and write something like:

$result = $pdo->fetchAssoc($stm, $bind);
list($value1, 
     $value2,
     $value3
) = array_keys($result);

But isn't it a bit impractical? Do you have any plans of implementing a function that returns a result as numeric array? (PDO:FETCH_NUM

from aura.sql.

pmjones avatar pmjones commented on August 23, 2024

This particular case ...

$result = $pdo->fetchAssoc($stm, $bind);
list($value1, 
     $value2,
     $value3
) = array_keys($result);

... might be addressed by:

$values = $pdo->fetchCol($stm, $bind);

That will populate $values with the first column of all rows in the result set. (Note that fetchAssoc() uses the first column as the array key.)

Is that sufficient, or is there another case that needs to be addressed?

from aura.sql.

pmjones avatar pmjones commented on August 23, 2024

@gholol Any further thoughts?

from aura.sql.

gholol avatar gholol commented on August 23, 2024

Hi!

Sorry for not responding, i was at work.

Your suggestion to use fetchCol() was right, it works perfectly ;) So i don't have anything else to rant about.

Have a nice day guys!

from aura.sql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.