Author Topic: Can PHP call a C functiont that reyurns a pointer to a structure (a linked list)  (Read 632 times)

0 Members and 1 Guest are viewing this topic.

Offline A.P.Topic starter

  • Irregular
  • Posts: 1
    • View Profile
Can PHP call a C functiont that reyurns a pointer to a structure (a linked list)?

I am a C programmer and am writing C functions to do database access. The results are converted into linked lists.

Currently the PHP programmers are writing their own SQL statements to directly access the datbase, but the intention is for all DB access to be done via the C libraries I am writing. Howver our PHP programmers do not know how to implement this, and I don;t know PHP!

Offline jesirose

  • Fanatic
  • Posts: 3,819
  • Gender: Female
  • PHP Goddess
    • View Profile
    • Reed's Training Blog
Why are you writing C Libraries for a PHP program? It seems like the PHP programmers should be making their library in PHP.

I don't believe PHP can access C this way...
Every time you post "It didn't work" without more explanation, God kills a kitten.
When you post code without code tags, He just teases a puppy. But it's still sad.
What does that php function do? | What does that term mean? | I don't see any errors! | Awesome API Interface
PHP Goddess with Attitude since 2004

Offline ShogunWarrior

  • Devotee
  • Posts: 533
  • Gender: Male
  • # IRELAND #
    • View Profile
    • David Doran Media
I think you would need to return a "Resource" type and expore iterator functions to PHP.
E.g:
Code: [Select]
$handle = call_your_query( $input );
while( $row = get_data_row($handle) )
{
    // Echo data etc..
    //echo '';
}

Both call_query and get_data_row for example would be your functions and so the first function would return a resource which PHP supports and the second function would return an array which PHP supports.
<a href="http://www.daviddoranmedia.com/">My New Site/Blog</a> | <a href="http://www.daviddoranmedia.com/check/">Check your page for broken links/images/scripts</a>

Zend Certified Engineer
Follow me on Twitter: http://twitter.com/davidd