getOne / PGetOne

Executes the SQL and returns the first field of the first row. If an error occurs, false is returned.

Parameters

getOne($sql)
$sql:The MySQL query to perfom on the database.

Prepared statements Parameters

PgetOne($sql, $varN)
$sql:The MySQL query to perfom on the database
$varN:The variable(s) that will be placed instead of the ? placeholder separated by a ‘,’ or it can be the method Prepare.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
<?php

require_once 'dalmp.php';

$user = getenv('MYSQL_USER') ?: 'root';
$password = getenv('MYSQL_PASS') ?: '';

$DSN = "utf8://$user:$password".'@127.0.0.1/test';

$db = new DALMP\Database($DSN);

$rs = $db->PGetOne('SELECT * FROM Country WHERE Region = ? LIMIT 1', 'Caribbean');

Output of echo $rs:

1
Aruba

Thanks Navicat for supporting Open Source projects.

Navicat



A great amount of time has been spent creating, crafting and maintaining this software, please consider donating.

Donating helps ensure continued support, development and availability.

dalmp


comments powered by Disqus