İlk olarak şunu belirtmek istiyorum, PHP ile MYSQL yapısına bağlantıyı hemen hemen herkes bilir connect ve select_db fakat kullandığım PHP sürümünde store procedure call ederken bir bug oluşuyormuş ve bendede bu bug oluştuğu için mysqli yapısını kullanacağım, mysqli yapısı hakkında bilgi almak istiyorsanız.
http://www.php.net/manual/en/mysqli.overview.php okumanızı tavsiye ederim. Syntax bir daha OOP dayalı. Hatta belirgin özelliklerini yazmışlar bende paylaşayım.
■Object-oriented interface
■Support for Prepared Statements
■Support for Multiple Statements
■Support for Transactions
■Enhanced debugging capabilities
■Embedded server support
--
-- Tablo yapısı: `tbltest`
--
CREATE TABLE IF NOT EXISTS `tbltest` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`News` text COLLATE utf8_turkish_ci,
`NewsAuthor` varchar(50) COLLATE utf8_turkish_ci DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_turkish_ci AUTO_INCREMENT=2 ;
--
-- Tablo döküm verisi `tbltest`
--
INSERT INTO `tbltest` (`ID`, `News`, `NewsAuthor`) VALUES (1, 'Haber testidir.', 'gökalp');
CREATE DEFINER = 'root'@'localhost'
PROCEDURE workspacedb.fetchDependsOnID(IN _ID INTEGER (11))
BEGIN
SET @USING_ID = _ID;
SELECT
*
FROM
WORKSPACEDB.tbltest
WHERE
TBLTEST.ID = @USING_ID;
END
< ?php
$mysqli = mysqli_init();
$mysqli->real_connect("localhost","root","","workspacedb");
if ($re = $mysqli->real_query("call fetchDependsOnID(1)"))
{
if($objResult = $mysqli->store_result())
{
while($row = $objResult->fetch_assoc())
{
$arr[]=$row;
}
//OUT:Array ( [0] => Array ( [ID] => 1 [News] => Haber testidir. [NewsAuthor] => gökalp ) )
print_r($arr);
$objResult->free_result();
}
}
?>
Add a Comment
0 Comments
If you missed any of the previous OSUM Webinars, click here to listen to the replays of the previous sessions.
Get On Board with JavaFX & the Tech Train Game
Get a hands-on introduction to JavaFX when you play the Tech Test Train - Ride the train, test your knowledge of JavaFX technology, and earn points. Click HERE to play.
Working With ZFS Snapshots Download the free ZFS Snapshots How-To Guide to learn how to create and use the backup and restore capabilities of ZFS snapshots.© 2009 Created by Gary Serda
You need to be a member of Open Source University Meetup to add comments!
Join this social network