public static function getInstallApp(User $user, $app_id) { $sql = 'SELECT * FROM app_install_user WHERE mail = :mail AND app_id = :app_id'; $bind = array(':mail' => $user->getMail(), ':app_id' => $app_id); $row = mfwDBIBase::getRow($sql, $bind); if (!$row) { return null; } return new InstallApp($row); }
/** * select single object. * @return instance of OBJECT_CLASS. */ protected static function selectOne($query, $bind = array(), $con = null) { $table = static::TABLE_NAME; $sql = "SELECT * FROM `{$table}` {$query}"; $row = mfwDBIBase::getRow($sql, $bind, $con); if (empty($row)) { return null; } $class = static::SET_CLASS; return $class::hypostatize($row); }
public static function updateCursor($repo_id, $cursor, $con = null) { $cursor_table = 'repository_cursor'; $sql = "SELECT * FROM {$cursor_table} WHERE repo_id=?"; $row = mfwDBIBase::getRow($sql, array($repo_id), $con); if (empty($row)) { $sql = "INSERT INTO {$cursor_table} (repo_id,number) VALUES (:repo_id,:number) ON DUPLICATE KEY UPDATE number=:number"; } else { $sql = "UPDATE {$cursor_table} SET number=:number WHERE repo_id=:repo_id"; } $bind = array(':repo_id' => $repo_id, ':number' => $cursor); return mfwDBIBase::query($sql, $bind, $con); }