" ); print_r( $properties ); print( ""); $list = []; foreach ( $properties as $key => $val ) { if ( is_object( $val ) ) { foreach( $val as $subkey => $subval) { $list[] = [$subkey, $key]; } } else { $list[] = [$key, '']; } } print("
");
print_r( $list );
print("
"); $pdo = null; try { $pdo = new PDO("sqlite:" . "${db_path}/slork.sqlite"); } catch (PDOException $e) { // handle the exception here } if ( !$pdo ) { exit( "Cannot connect to database" ); } $query = "DROP TABLE IF EXISTS properties;"; $pdo->exec( $query ); $query = <<exec( $query ); $query = "INSERT INTO properties (property, parent) VALUES (?, ?) ON CONFLICT (property) DO NOTHING;"; $stmt = $pdo->prepare( $query ); foreach ( $list as $item ) { $stmt->execute( $item ); } /** $query = "SELECT property FROM properties;"; $stmt = $pdo->query( $query ); foreach( $stmt as $row ) { print( $row['property'] . ', '); } */