MysqliDb::inc PHP Method

inc() public method

Method generates incremental function call
public inc ( integer $num = 1 ) : array
$num integer increment by int or float. 1 by default
return array
    public function inc($num = 1)
    {
        if (!is_numeric($num)) {
            throw new Exception('Argument supplied to inc must be a number');
        }
        return array("[I]" => "+" . $num);
    }

Usage Example

コード例 #1
0
ファイル: vote.php プロジェクト: rahulrk95/kulizahack
<?php

require_once 'MysqliDb.php';
/* updates voting colums for upvote and downvote */
$pid = $vote = $db = new MysqliDb('localhost', 'root', 'hack123', 'colgpolls');
if ($vote == 'yes') {
    $data = array('upvote' => $db->inc(1));
} else {
    $data = array('downvote' => $db->inc(1));
}
$db->where('pid', $pid);
$db->update('polls', $data);