PHP code example of efoft / active-records

1. Go to this page and download the library: Download efoft/active-records library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

efoft / active-records example snippets


$ar->setHandlerAttrt('cascade', false);

$ar->setTable('table1');

$ar->add($data, 'table2');

$data = array(
  'name' => 'Testuser2',
  'age'  => '36'
);

$ar->add($data);

$ar->setMandatoryFields(array('name','age'));

$ar->setUniqueRecordFields(array('name','age'));

if ( $inserted = $ar->add($data) )
{
  echo "inserted id: $inserted <br>";
}
else
{
  if ( $errors = $ar->getError() )
    foreach($errors as $k=>$v)
      echo "$k: msg: $v['errmsg'], extended info: $v['extinfo']<br>";
}

$ar->update(array('id'=>'12'), array('age'=>'36','name'=>'Testuser2'));

$ar->update(array('tags'=>'three'),array('age'=>33, '$addToSet'=>array('tags'=>'two','imgs'=>'jack1.jpg')));

$ar->delete(array('age'=>'36'));