completely understanding records lists and where to learn more

5 posts by 3 authors in: Forums > CMS Builder
Last Post: October 12, 2011   (RSS)

Re: [rez] completely understanding records lists and where to learn more

Hi Rez,

Three suggestions.

One is to look for answers to questions here in the forum. The more specific the better.

The second is to explore my CMSB Cookbook thecmsbcookbook.com for more on how to accomplish various advanced tasks.

The third would be to do exactly what you've done here. Post specific questions on the forum.

Hope that gives you some ideas.

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] completely understanding records lists and where to learn more

By rez - October 12, 2011

Thanks Jerry. I look for answers in the forum all the time. I also have your cookbook. I'm trying to put the missing pieces together. I'm doing too much that works and only basically understanding what's going on. I used to work at a micro lab where everyone just followed the procedures. I took home the manuals and a medical dictionary to understand the inner workings of all the machines. Eventually people were coming to me for answers when things went wrong and I advanced quickly as the problem solver for situations in other labs / states.

Although I dont want to solve everyone elses problems here and will never match people like Jason, I want to learn more and understand the inside of the machine. Maybe then i'll know exactly what PHP and mySQL to learn? Where is my manual to cross reference with the PHP site or a Lynda tutorial? I feel like i could watch a lynda tutorial on PHP and mySQL but it still may not apply exactly to where i should go next here?

Re: [rez] completely understanding records lists and where to learn more

By Jason - October 12, 2011

Hi,

You're right, the lines between CMSB, PHP, and MySQL do get a little blurry. In its most basic sense, CMS Builder is a collection of functions written is PHP to allow you to easily manipulate information inside a MySQL database. The getRecords() function, for example, is a PHP function we wrote that takes some simple options from you and uses that to create SQL statements which it executes and then returns the results.

In the case of your first question concerning list(), if we take a look at the example you gave:

list($myRecords, $myMetaData) = getRecords(array(
'tableName' => 'my_table',
));


there are a couple of different things going on. Basically, getRecords will take all of the records from the table "my_table" and put them into the array $myRecords.

The list() part is a PHP language construct that allows us to return multiple variables with a single return statement. What it does is takes an array, and assigns each part of the array a variable in the list. The getRecords() function is actually returning an array of arrays. If we look at the return statement inside that function, this is what we see:

return array($rows, $listDetails, $schema);

$rows is an array of all the records being returned. $listDetails is an array of information about those records (ie, how many were returned, how many pages of information there will be, which page are we currently on, etc). Finally $schema is the schema of the section the records came from. list() takes each one of these arrays and assign them to a variable: $rows gets assigned to $myRecords, $listDetails gets assigned to $myMetaData.

A great way to see the structure of what's being returned is to use the CMSB function showme(). If you pass an array to this function, it will show you a break down of how the entire array is structured and what is stored in each element. So, to see exactly what the results of your getRecords call, you could do this:

list($myRecords, $myMetaData) = getRecords(array(
'tableName' => 'my_table',
));

showme($myRecords);
showme($myMetaData);


Hope this helps to clarify a little. I find the best way to learn is to experiment with the different functions you come across, whether they're from PHP or CMS Builder. This is something I still do all the time when working with different parts of CMS Builder. If you ever get stuck, let us know and we'll see if we can explain it more clearly.
---------------------------------------------------
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: [Jason] completely understanding records lists and where to learn more

By rez - October 12, 2011

Definitely clarifies things for me a bit more and what to look into next. I was completely backwards on some things and wasn't even totally clear that getRecords was a CMSB function and list was in the PHP manual.

I'll check out those showme functions. Thanks for the direction.