Pulling select fields from records

5 posts by 3 authors in: Forums > CMS Builder
Last Post: December 16, 2010   (RSS)

Without resorting to straight SQL, how can you pull only specified fields from tables?

Normally, it would be something like:
SELECT title FROM <table>....

I can't see anyway to limit the fields that are selected using the commands that are accepted by CMS Builder.

Help?
WebCamp One, LLC



Websites That Work

Re: [Mr Jim] Pulling select fields from records

By Jason - December 16, 2010

Hi,

There isn't an option to limit the fields being returned by getRecords. The quickest way to do this would be to just use straight sql.

If you're interested, we can accomplish this for you with some customization.

Can you give an example where you would need to limit the number of fields returned without using plain sql?

Let me know.
Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Mr Jim] Pulling select fields from records

By Chris - December 16, 2010

Hi Mr Jim,

Sometimes straight SQL is the way to go. Something like this should work for you:

$escapedTableName = mysql_escape(getTableNameWithPrefix('my_section_name');)
$records = mysql_query_fetch_all_assoc("SELECT num, name FROM `$escapedTableName`");
showme($records);


I hope this helps! Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Pulling select fields from records

By MisterJim - December 16, 2010 - edited: December 17, 2010

Thanks, Chris. That worked like a charm.

Jim
WebCamp One, LLC



Websites That Work