This topic is locked
[SOLVED]

 LOoking for code samples to do things like ...

5/27/2020 5:02:11 PM
PHPRunner General questions
B
bobalston author

LOoking for code samples to do things like
Read all records from a table in a loop
Add a new record in another table
Thanks
Bob

K
keithh0427 5/27/2020

Here are some examples from the Help file. It's a great place to start.

  1. Select all records
    $rs = DB::Select("Cars", "Price<20000" );

    while( $record = $rs->fetchAssoc() )

    { echo $

    record["id"];

    echo $record["make"];

    }
  2. Copy a record into another table
    // Copy the record into the 'Copy_of_cars' table

    $data = array();

    $data["make"] = $values["make"];

    $data["model"] = $values["model"];

    $data["price"] = $values["price"];

    DB::Insert("copy_of_cars", $data );
    I have found that the manual provides many examples.

B
bobalston author 5/28/2020

Thanks very much.
I agree there are many examples of code in the documentation. What I find is it is difficult to find the code I am looking for.
UPDATE: Just found the Database Api
bob

Sergey Kornilov admin 5/28/2020

Hard to tell what exactly causes the trouble finding code examples. The official Database API can be found at https://xlinesoft.com/phprunner/docs/about_database_api.htm
The example of looping through data results:

https://xlinesoft.com/phprunner/docs/db_select.htm