Romanian PC Forum Sabitech Media - web design, gazduire web, promovare, seo, logo design si branding

Go Back   Romanian PC Forum > Software > Programare > Web

Web Totul despre web programming... dezbateri, nelamuriri, tutoriale...

Thread Tools
Old 21.10.2011, 20:10   #1
RPC Gold Member
Join Date: 02.03.2011
Age: 42
Posts: 978
Thanks: 20
Thanked 1,091 Times in 583 Posts
Default Un mic wrapper peste functiile mysql


class MySQL {
	private function __construct() {
		$user = "username";
		$pass = "parola";
		$db = "database";
		self::$connected = false;
		if(mysql_connect("localhost", $user, $pass))
				self::$connected = true;

	public static function query($sql) {
		self::$recordset = false;
		if(self::$connected) {
			self::$recordset = @mysql_query($sql);
			if(self::$recordset) return true;
		return false;

	public static function fetch() {
		if(self::$recordset) {
			return @mysql_fetch_array(self::$recordset);
		return false;

	public static function lastid() {
			return @mysql_insert_id();
		return false;

	public static function lookup($sql) {
		self::query("$sql LIMIT 1");
		return self::fetch();

	public static function escape($str) {
			return mysql_real_escape_string($str);
		return "";

	public static function connect() {
			self::$instance = new self();
		return self::$instance;

	private static $instance;
	private static $connected;
	private static $recordset;

Exemplu de utilizare:


include "mysql.php";

$sql = "SELECT produs, pret FROM produse ORDER BY produs";

while($row = MySQL::fetch()) {
  list($produs, $pret) = $row;
    <td><?= $produs ?></td>
    <td><?= $pret ?></td>

PS @xvanish: ar fi util un plugin la forum care sa stie sa faca syntax-highlighting la codurile sursa (php, c++ etc).
Imi place Romanian PC Forum -!
sdw is offline   Reply With Quote
The Following User Says Thank You to sdw For This Useful Post:
Alin99 (21.10.2011)
Old 22.10.2011, 15:58   #2
RPC Administrator
XVanish's Avatar
Join Date: 03.06.2008
Location: Baia Mare
Age: 37
Posts: 5,965
Thanks: 3,662
Thanked 3,376 Times in 1,985 Posts
Send a message via Yahoo to XVanish Send a message via Skype™ to XVanish
Default Re: Un mic wrapper peste functiile mysql

Da, e o idee buna, o sa caut.
Internetul e distractie, nu pierde controlul!

Foloseste Google si YouTube inainte de a pune intrebari stupide!
XVanish is online now   Reply With Quote


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tutorial - C ] Accesarea unei baze de date mysql High Devil Programare 5 26.06.2010 19:07
La peste kittmask Galerie foto 1 25.01.2010 21:38
Un peste este mancat de viu intr-un restaurant din China XVanish Offtopic 0 19.11.2009 10:05
problema Windows - se baga programele unul peste altul georgester Suport Tehnic 2 29.04.2009 15:08


camere foto digitale

aparate foto digitale

Partner Links
Sabitech Media - dezvoltare web, servicii media

RSP Forum -
Comunitate Satelitara

All times are GMT +2. The time now is 19:31.

Powered by vBulletin® - © Jelsoft Enterprises Ltd.
~ Copyright © 2007-2015 Romanian PC Forum ~
Toate drepturile rezervate

Romanian Sattelites Provider Wi-Fi Magazin