Insert custom mysql with viewer_functions

3 posts by 2 authors in: Forums > CMS Builder
Last Post: March 17   (RSS)

By AlanAlonso - March 16

Is there a shortcut using viewer_functions to insert custom mysql to the cmsb database, to avoid using this?

$conexion = mysqli_connect("localhost","user","pass","database");
	die('No se puede conectar '.mysql_error());
if (mysqli_query($conexion, $output )) {
    header("Location: alumnos.php");
} else {
    echo mysqli_error($conexion);
mysqli_close ($conexion);

By Dave - March 17

Hi Alan, 

We have a few internal functions you can use.  Here are some options: 

$colsToValues = [
  'title' => 'test title',
  'content' => 'test content',

$newRecordNum = mysql_insert($tableName, $colsToValues);

Or you can get the mySQL object directly with mysqli() like this: 

$result = mysqli()->query($query);
if (!$result) { dieAsCaller("MySQL Error: ". htmlencode(mysqli()->error) . "\n"); }

Hope that helps!  Let me know any questions.

Dave Edis - Senior Developer